getting getSignedRequest() using static HTML app? - php

I have an app called static HTML (https://apps.facebook.com/static_html_plus/?ref=ts) installed on a page of mine..
I want to be able to access getSignedRequest() to pass data through the URL in facebook using app_data.. (I want to be able to pass an item id to activate a JS item in the iframe.. in essence allowing me to link to an expanded JS feature in the page)
The issue is that i am recieving NULL from getSignedRequest(); I am not sure if the app I am using (mentioned above : static HTML) is stopping the information from getting passed through to my iframe.
If you are unfamiliar with this app, it allows you to put HTML/CSS/JS to embed an iframe.
On the hunch that it is the app that is stopping the propagation of the facebook data to my iframe, I have attempted to follow SEVERAL tutorials, both video and written that try to create a facebook iframe by creating a custom app.. none have worked, and i have not been successful in even adding a BASIC TAB to any of my pages..
I am about to give up on this facebook thing as every tutorial I have found has a completely different looking interface or set of instructions then what is ACTUALLY available on the facebook developers page..
Does anyone have a CLEAR UP-TO-DATE, non-facebook written walk-through, or atleast know if my use of the static HTML app is what is causing me to recieve null in my getSignedRequest()?
Here is my php code in the iframe i embed in the static HTML app, incase you think the error is in there somewhere.
require 'facebook.php';
//facebook signed app_data
$app_id = "xxxxxx";
$app_secret = "xxxxxxxxxxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
// Get contents of signed request
$signed_request = $facebook->getSignedRequest();
Any help would be nice. I have wasted 2 nights on this crap.

.html files cannot accept HTTP POSTs unless the web-server is configured to accept this verb. However, the only way to get at the post parameters is with server-side code and cannot be done clientside.

Related

when attempting to connect to facebook with PHP script endless redirects

first facebook asks me to click okay to authorize the app then chrome gives me this error. and the I have this endless redirect problem. I have read many cases about this but none clear and simple enough to get me over this obstacle.
The webpage at __________&redirect_uri=http%3A%2F%2Fmizu.net46.net%2Ffacebookpost6.php&state=_________________&sdk=php-sdk-3.2.3&req_perms=user_status%2Cpublish_stream%2Cuser_photos%2Coffline_access%2Cmanage_pages#=">https://www.facebook.com/dialog/oauth?client_id=__________&redirect_uri=http%3A%2F%2Fmizu.net46.net%2Ffacebookpost6.php&state=_________________&sdk=php-sdk-3.2.3&req_perms=user_status%2Cpublish_stream%2Cuser_photos%2Coffline_access%2Cmanage_pages#= has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
what I know.
facebook.php is working
the secret and appid are being passed correctly by the script.
I must have configured my app settings on the facebook development site almost correctly
how do I know this?
because when I change those variables in my script or adjust the settings
on facebook development server, I dont even get this far, I dont get asked to click ok or see my facebook profile in chrome.
what I dont know.
How to fix this redirect problem. or complete the authentication process. echo $user always returns 0.
my code looks like this:
require 'src/facebook.php';
$app_id = "xxxxxxxxxxxxxxxxxx";
$app_secret = "xxxxxxxxxxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$user = $facebook->getUser();
echo $user;
if(($facebook->getUser())==0)
{
header("Location:{$facebook->getLoginUrl(array('req_perms' =>
'user_status,publish_stream,user_photos,offline_access,manage_pages'))}");
exit;
}
thanks for any help
changing the setting to no when asked" is this a desktop app? " in the advanced section of app configuration on developers.facebook.com seem to resolve this issue.

$facebook.getUser(); returning all the time 0

I'm posting here due to a problem with php and the sdk of facebook.
For a reason I don't really know, when I try to get the userID of the logged account, continuously I received the same value, 0, even if i'm logged.
I've been trying to debug some variables, $facebook, checking sessions, etc. but with unsuccessfully results, then i'm gonna step by detailing all what i'm doing and the debug log i'm doing:
I'm using hostinger servers, that hosts my website. Due to i've found many problems, i've created a test webpage in which i have 5 files:
index.php
callback.php
facebook.php (comes from facebook)
base_facebook.php
certificate
The code i have on index.php is what i've pasted here: [index.php]: http://pastebin.com/Mfdkxz8H This is only the first part of the code which tries to get the autentification.
The code i have on callback.php is what i've pasted here: [callback.php]: http://pastebin.com/Uw0A3NM8. There i try to get the userID.
I've read some post and for some reasons there were so many cases in which the token
wasn't received in the second file/call.
I don't really know what the problem is and would be happy to find a solution.
P.D It doesn't matter the appId and secret because facebook and webpage were created for a test.
Hard to tell what is going up from your code example (By the way, you should NEVER post your appId and secret in public like that otherwise someone will be able to compromise your application). A gave your code a quick glance and it "looks" fine but here are a couple of pointers:
But here are a couple of pointers.
1) Make sure you have the latest version of the Facebook SDK (assuming you do)
2) For SANITY sake, i would keep your Facebook API files in its their folder ('sdk')
3) DOUBLE CHECK your app settings to make sure the appID and secret are correct (I have made this mistake many times), also make sure that your at is NOT in sandbox mode
4) Then try something like this
include_once("sdk/facebook.php");
//Call Facebook API
$facebook = new Facebook(array(
'appId' => XXXXXXXXXXXXXXXX,
'secret' => XXXXXXXXXXXXXXXX,
'cookie' => true, // enable optional cookie support
));
$params = array(
'scope' => 'email',
'redirect_uri' => 'http://devstarlight.esy.es/facebook/callback.php'
);
$login_url = $facebook->getLoginUrl($params);

Facebook Graph API requests on page events returns empty result array

I created a PHP script a year ago, that requests the events from a Facebook page, and it still works fine- except for one page and only since recently.
$config = array();
$config[ 'appId' ] = '468554113184955';
$config[ 'secret' ] = 'APP_SECRET';
$config[ 'fileUpload' ] = false; // optional
$facebook = new Facebook( $config );
$res = $facebook->api( '/Stadtpalais/events?fields=id,name,start_time,description,updated_time,picture.type(large)', 'GET' );
I also tried the request with another app ending with the same result, so I think retrieving a new app secret wouldn't help.
The script is just working with appId and secret, but without any user login. Try the Graph explorer with any app access token like '468554113184955|APP_SECRET' (use your own ID and secret) to reproduce the error. Change the page to any other page and it will work.
Can page admins prevent these public requests through settings? (I haven't found one yet.)
Could an event title or description or whatever trigger an error so that Facebook sends an empty array?
Some time ago I read that Facebook might force a user login to request the events, but since it's working fine with other pages, I'd think that hasn't happened yet?
Thanks in advance!
I can now answer my own question: It's due to the page setting
Age Restrictions = Alcohol-related

facebook api login issue

Im trying to retrieve data from
http://www.facebook.com/ajax/shares/view/?target_fbid=410558838979218&__a=1
I get mix of js and html with sharing information if I open this link through my browser, but if I use
$url = 'http://www.facebook.com/ajax/shares/view/?target_fbid=410558838979218&__a=1';
$html = file_get_contents($url);
I get
"Not Logged In","errorDescription":"Please log in to continue.","payload":{"_dialog":{"title":{"_html":"Not Logged In"},"body":{"__html":"Please log in to continue.................
and etc
I understand that i need to be logged in, i tried login through facebook api:
$config = array(
'appId' => '**********',
'secret' => '**********',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
Im gettin user and etc, everything's okay, but retreiving share information fails anyways
How can I "properly" login to solve this issue?
Thanks
You're using the SDK initialisation code but trying to scrape facebook.com's web interface - these are not compatible things
You'd need to automate the login to facebook.com via your code as well and handle all the cookies if you want to scrape, buy doing so is explicitly against Facebook's TOS and could get you in legal trouble if you persist

Why can I not establish access to my Facebook app?

I am following the instructions on this page to create a PHP script which will (hopefully) allow me to post to Facebook from my web site.
All I really want to establish is the ability to enter text and a link into a form on my web site and have it be posted to a Facebook wall.
My understanding is that I need to validate a Facebook app in order to do this, which is what brought me to the above web page.
I have followed their instructions dutifully, and by now I have been through it many times, checking to make sure I have followed their steps accurately.
However, when it gets to the part where I run fb_access.php from my web site, I get absolutely no response from Facebook.
I notice that the screen shot examples on the page I am using are not what I am seeing in the Facebook interface. The tutorial is from December 2010, which I would hope is recent enough, but perhaps things have changed...?
How do I get Facebook to respond to my PHP script?
<?
require_once 'facebook.php';
$app_id = "<my App ID";
$app_secret = "<my App Secret>";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
if(is_null($facebook->getUser()))
{
header("Location:{$facebook->getLoginUrl(array('req_perms' => 'user_status,publish_stream,user_photos'))}");
exit;
}
?>
Try using the Facebook PHP SDK demo script here:
https://github.com/facebook/php-sdk/blob/master/examples/example.php
Once you have this script running - you can then begin to request calls, such as post to wall. If the call is successful, FB will prompt you with a Request for Permission.

Categories