I am using graph api to exchange access token in one of my application, but sometime its returns blank output.
I am using this code snipet
$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];
It will return black response sometime
Any help will appreciate.
Thank you
Yes, you can solve this issue. Use the following code
<?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'];
?>
I hope that this will help you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.