[英]Why does getAccessToken() return a shorter string than a manual call to https://graph.facebook.com/oauth/access_token?
I'm doing the following whilst testing out the PHP-SDK: 在测试PHP-SDK时,我正在做以下工作:
if($_REQUEST['state'] == $_SESSION['state']) {
$token_url = "https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret . "&code=" . $code;
$aContext = array( 'http' => array(
'proxy' => 'tcp://192.168.55.40:80',
'request_fulluri' => true,
),
);
$cxContext = stream_context_create($aContext);
$response = file_get_contents($token_url, FALSE, $cxContext);
$params = null;
parse_str($response, $params);
//$graph_url = "https://graph.facebook.com/me?access_token=" . $params['access_token'];
//$user = json_decode(file_get_contents($graph_url, FALSE, $cxContext));
//var_dump($facebook->getAccessToken());
$facebook->setAccessToken($params['access_token']);
$user = $facebook->api('/me');
var_dump($user);exit;
$facebook->getAccessToken() returns a string of 48 chars. $ facebook-> getAccessToken()返回48个字符的字符串。 and params['access_token'] is 112 chars. params ['access_token']为112个字符。 Why is this? 为什么是这样? What do I need to do to get a valid access token using the SDK? 我需要做什么才能使用SDK获得有效的访问令牌?
Its an app access token, not a user access token. 它是应用程序访问令牌,而不是用户访问令牌。
Try using SDK's getAccessToken instead. 尝试改用SDK的getAccessToken。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.