Exception trying to post a link on Facebook page using grahp API for PHP -
i've searched among other questions here on stackoverflow , on other websites, couldn't find solution, because seems fb changes authentication method, old solutions no more valid.
i'm using sdk4 , code have @ moment
facebooksession::setdefaultapplication($app_id, $app_secret); $session = facebooksession::newappsession(); try { $session->validate(); } catch (facebookrequestexception $ex) { echo $ex->getmessage(); } catch (\exception $ex) { echo $ex->getmessage(); } if($session) { try { $response = (new facebookrequest( $session, 'post', '/me/feed', array( 'link' => 'www.mysite.it', 'message' => 'some text' ) ))->execute()->getgraphobject(); echo "posted id: " . $response->getproperty('id'); } catch(facebookrequestexception $e) { echo "exception occured, code: " . $e->getcode() . " message: " . $e->getmessage(); } }
i message:
"exception occured, code: 2500 message: active access token must used query information current user."
given message, session correctly created , validated, problem on execute() method, how fix it?
it looks you've created session app, post on users behalf need access token said user , call
$this->facebook = new facebooksession($access_token);
Comments
Post a Comment