php - An active access token must be used to query information about the current user & OAuthException [code] => 2500 -


when user access token , getting error . please me immediately. how can solve this,tell me

stdclass object ( [error] => stdclass object ( [message] => active access token must used query information current user. [type] => oauthexception [code] => 2500 ) )

require 'facebook-php-sdk-v4/src/facebook/autoload.php'; require("facebook.php");  $fb = new facebook\facebook([   'app_id' => '1501716620042981',   'app_secret' => '510d15193610ca682b7f79c156992bb5',   'default_graph_version' => 'v2.3',   ]); $helper = $fb->getredirectloginhelper();   try {   $accesstoken = $helper->getaccesstoken(); } catch(facebook\exceptions\facebookresponseexception $e) {   // when graph returns error   echo 'graph returned error: ' . $e->getmessage();   exit; } catch(facebook\exceptions\facebooksdkexception $e) {   // when validation fails or other local issues   echo 'facebook sdk returned error: ' . $e->getmessage();   exit; }  if (isset($accesstoken)) {   // logged in!  echo $_session['facebook_access_token'] = (string) $accesstoken;    // can redirect page , use   // access token $_session['facebook_access_token'] }          $curl_handle=curl_init();     curl_setopt($curl_handle, curlopt_url,'https://graph.facebook.com/me/?fields=albums.fields(id,name,cover_photo,photos.fields(name,picture,source)),videos.type(uploaded)&'.$_session['facebook_access_token']);     curl_setopt($curl_handle, curlopt_connecttimeout, 2);     curl_setopt($curl_handle, curlopt_returntransfer, 1);     curl_setopt($curl_handle, curlopt_useragent, 'fb');     curl_setopt( $ch, curlopt_httpheader, array('content-type:application/json'));     # return response instead of printing.     $query = curl_exec($curl_handle);     curl_close($curl_handle);       print_r(json_decode($query)); 

you're not providing access token in right way. should presented value of access_token url query parameter in:

'https://graph.facebook.com/me/?fields=albums.fields(id,name,cover_photo,photos.fields(name,picture,source)),videos.type(uploaded)&access_token='.$_session['facebook_access_token'] 

for clarity, without specific fields:

'https://graph.facebook.com/me?access_token='.$_session['facebook_access_token'] 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -