繁体   English   中英

Exchange访问令牌有时在Facebook图形api中不返回输出

[英]Exchange Access Token does not return output sometime in facebook graph api

我正在使用图谱api在我的一个应用程序中交换访问令牌,但有时它返回空白输出。

我正在使用此代码片段

$graph_url      = "https://graph.facebook.com/oauth/access_token?client_id=" .$app_id."&client_secret=" .$app_secret."&grant_type=fb_exchange_token&fb_exchange_token=".$user_access_token;
            $response       = @file_get_contents($graph_url);
            $response_arr   = explode('&',$response);

            $exchanged_user_access_token = explode('=',$response_arr[0]);
            return $exchanged_user_access_token[1];

它将在某些时候返回黑色响应

任何帮助将不胜感激。

谢谢

是的,您可以解决此问题。 使用以下代码

<?php
$graph_url      = "https://graph.facebook.com/oauth/access_token?client_id=" .$app_id."&client_secret=" .$app_secret."&grant_type=fb_exchange_token&fb_exchange_token=".$user_access_token;
$response       = @file_get_contents($graph_url);
parse_str($response,$output);
$extended_access_token = $output['access_token'];
?>

希望对您有帮助

暂无
暂无

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

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