Reputation: 178
How to get long life access_token using curl and store in variable ?
My web host unable to use file_get_contents() due to some reasons thats why i am unable to use this so that next option is available for me is to use CUrl i known about that and learn but i didn't understand.
below is the url which we use to get long life access_token note i already store access_token in $atoken
https://graph.facebook.com/oauth/access_token?client_id="id"&client_secret="its seceret ;)"&grant_type=fb_exchange_token&fb_exchange_token=$atoken
Thanks
Upvotes: 2
Views: 1782
Reputation: 10074
Make simple cURL request like that
$url = 'https://graph.facebook.com/oauth/access_token?client_id="id"&client_secret="its seceret ;)"&grant_type=fb_exchange_token&fb_exchange_token=$atoken';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "I-am-browser");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
curl_close($ch);
var_dump(json_decode($response, true));
Upvotes: 1