简体   繁体   English

如何在Facebook PHP sdk中获取用户ID?

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

I'm having the toughest time figuring this out... how can I get the user ID? 我在解决这个问题上花费了最艰苦的时间...如何获取用户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? 如何获得用户ID? I get the access token by using $GET_['access_token']; 我通过使用$GET_['access_token'];获得访问令牌$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). 这是URL: http : //friendsconnect.org/example.php?access_token=ACCESS_TOKEN_HERE#access_token=ACCESS_TOKEN_HERE&expires_in=0 (这不是有效链接)。 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: 来自: https : //github.com/facebook/php-sdk获取用户ID(假设已设置cookie或已传递访问令牌)的最小代码为:

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

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM