Sunday, 15 May 2011

php - App_access_token Always Returns False -



php - App_access_token Always Returns False -

according facebook docs, using app_access_token simple as:

$appid = 'xxx'; $secret = 'yyyyyyyyy'; $facebook = new facebook(array( 'appid' => $appid, 'secret' => $secret, 'cookie' => true, )); $session = $facebook->getuser()>0; if($session){ $access_token = 'access_token='.$facebook->getaccesstoken(); $app_access_token = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=$appid&client_secret=$secret&grant_type=client_credentials"); }

my problem $access_token fine but $app_access_token always returns false, doing wrong?

-edit-

if open app_access_token url in browser can see access token! seems fail file_get_contents... ?

the file_get_contents creating problems, may due php config settings. (discussion here: file_get_contents returns empty string)

i'll recommend utilize curl instead, that-

function get_content($url){ $ch = curl_init(); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_url, $url); $data = curl_exec($ch); curl_close($ch); homecoming $data; } echo get_content('http://example.com');

if problem persists, re-check values of app_id , secret in url.

php facebook facebook-graph-api facebook-php-sdk facebook-access-token

No comments:

Post a Comment