Can not post on a Facebook page as a admin using graph api php codeigniter -


i can not post on facebook page admin.it gives me error

exception occured, code: 200 message: (#200) user hasn't authorized application perform action 

although admin of page here permissions.i think have required permissions still code not working

["permissions"]=>     object(stdclass)#41 (1) {       ["data"]=>       array(5) {         [0]=>         object(stdclass)#42 (2) {           ["permission"]=>           string(12) "user_friends"           ["status"]=>           string(7) "granted"         }         [1]=>         object(stdclass)#43 (2) {           ["permission"]=>           string(5) "email"           ["status"]=>           string(7) "granted"         }         [2]=>         object(stdclass)#44 (2) {           ["permission"]=>           string(12) "manage_pages"           ["status"]=>           string(7) "granted"         }         [3]=>         object(stdclass)#45 (2) {           ["permission"]=>           string(15) "publish_actions"           ["status"]=>           string(7) "granted"         }         [4]=>         object(stdclass)#46 (2) {           ["permission"]=>           string(14) "public_profile"           ["status"]=>           string(7) "granted"         }       }  

here code

if (isset($session)) {             $_session['fb_token'] = $session->gettoken();             $session = new facebooksession($session->gettoken());               $request = new facebookrequest($session, 'get', '/me?fields=accounts{access_token,category,name,id,perms},permissions');             $response = $request->execute();              $graphobject = $response->getgraphobject()->asarray();             $fb_data = array(                 'me' => $graphobject,                 'loginurl' => $helper->getloginurl($facebook_default_scope),            );             $this->ci->session->set_userdata('fb_data', $fb_data);             /*facebook post*/                 try {                   $response = (new facebookrequest(                     1420447421611683 $page_id                     $session, 'post', '/1420447421611683/feed', array(                       'access_token'  => $fb_data['me']['accounts']->data[0]->access_token,                       'link' => 'www.example.com',                       'message' => 'whats up',                     )                   ))->execute()->getgraphobject();                   echo "posted id: " . $response->getproperty('id');                 } catch(facebookrequestexception $e) {                       echo "exception occured, code: " . $e->getcode();                       echo " message: " . $e->getmessage();                 }              /*end*/ } 

thanks in advance

this behavior design. you're missing permission publish_pages in access token. remember should use page access token post page.

here's documentation mentioning publish_pages: https://developers.facebook.com/docs/facebook-login/permissions/v2.3


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -