开发者

How can I get the user ID in the Facebook PHP sdk?

开发者 https://www.devze.com 2023-04-07 01:37 出处:网络
I\'m having the toughest time fi开发者_开发技巧guring this out... how can I get the user ID? While I relize the question sounds a bit retarded, I can\'t find this anywhere! This is my following top pa

I'm having the toughest time fi开发者_开发技巧guring this out... how can I get the user ID? While I relize the question sounds a bit retarded, I can't find this anywhere! This is my following top part of my code:

require '../fb_fc/facebook-php-sdk-9147097/src/facebook.php';
$appId     = 'APP_ID';
$appSecret = 'APP_SECERT';
$userId          = 'USER_ID?????';
$userAccessToken = 'ACCESS_TOKEN';

How can I get the user ID? I get the access token by using $GET_['access_token']; and this is the URL : http://friendsconnect.org/example.php?access_token=ACCESS_TOKEN_HERE#access_token=ACCESS_TOKEN_HERE&expires_in=0 (This is not a working link). How can I do this? I'm also new to this and am open to suggestions.


From: https://github.com/facebook/php-sdk The minimum code to get the user ID (assuming a cookie has been set or the access token already passed in) is:

require 'php-sdk/src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'YOUR_APP_ID',
  'secret' => 'YOUR_APP_SECRET',
));

// Get User ID
$user = $facebook->getUser();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号