Issue
I'm developing a Facebook application, and I want to retrieve some of the user's information on a side server while they are using the application.
In order to make that possible, I store the users access token in my database and pass it to the other server.
However, I am not sure how to use the access token to retrieve the user information. I am using the PHP SDK, and here is the usual code:
require '../src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '',
'secret' => '',
));
// Get User ID
$user = $facebook->getUser();
Where can I declare the access token?
Solution
It's very simple. If you enter a url like https://graph.facebook.com/me?access_token=theuseraccesstoken
(in your browser) you will receive a json file with the user information.
I'm pretty sure the facebook php sdk have a built in mechanism to do that (I'm a c# coder), but you are looking in the wrong place, because no api key or secret is necessary to access user information using a access token.
UPDATE1:
I think it works like this in the sdk
$facebook->setAccessToken($access_token);
$user = $facebook->getUser();
UPDATE2:
Or like this
$user = $facebook->api('me?access_token='.$access_token);
Answered By - lolol
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.