交换访问令牌不返回输出在facebook图形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'];
?>

我希望这对你有帮助

最新更新