0

我使用圖形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]; 

它會返回黑色響應某個

任何幫助會升值。

謝謝

回答

0

是的,你可以解決這個問題。使用下面的代碼

<?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']; 
?> 

我希望這將有助於你

+0

你明白了嗎? –

相關問題