Passing Facebook authentication from Javascript to PHP

I’m trying to set up offline access for my Facebook App. The javascript part is in place, having the user authenticated at all. However I can’t for the life of me seem to send the authentication data from javascript to PHP.Basically I am getting the access_token from the javascript getSession method, then I make my php request …

via PHP Website Development » Search Results » ajax:

Passing Facebook authentication from Javascript to PHP

I’m trying to set up offline access for my Facebook App. The javascript part is in place, having the user authenticated at all. However I can’t for the life of me seem to send the authentication data from javascript to PHP.
Basically I am getting the access_token from the javascript getSession method, then I make my php request with access_token=, however the PHP SDK detects that the access token matches the application access token and chickens out.
I have no idea why my access token is that of the application, maybe because I’m the dev?
For what it’s worth, this is the line where the Facebook SDK bails on me:
$access_token = $this->getAccessToken();
if ($access_token &&
$access_token != $this->getApplicationAccessToken() &&
!($user && $persisted_access_token == $access_token))
$user = $this->getUserFromAccessToken();
if ($user)
$this->setPersistentData(‘user_id’, $user);
else
$this->clearAllPersistentData();

}Can’t seem to highlight a line, it’s this line:
$access_token != $this->getApplicationAccessToken() &&Can anyone explain to me how I pass the authenticated user from Javascript to PHP?
Also, I assume that since the user has given permission for offline access I can store this access token for later use?
Thank you
…………………………………….

Well try using cookies, as both Javascript and php allows you to do it, if not, then AJAX is the best way to do it and getAccessToken() function basically fetches access token of user only if the user is connected and if the user is not connected,then it gets your application access token, echo getUser() and see what you get, if you get user’s id, then the user is connected to your application and if you get 0, then the user is not connected.
…………………………………….

Solved eventually by passing the access token as a GET parameter, then using API calls that accept manually supplying the access token. I was unable to figure out a way where it would handle this automatically.

For more info: Passing Facebook authentication from Javascript to PHP

PHP Website Development » Search Results » ajax

Passing Facebook authentication from Javascript to PHP

Share this post:

Related Posts

Leave a Comment