Auto post facebook in php -


i using following code auto post on facebook, shows me oauthexception.

$user_id = $facebook->getuser(); $page_info = $facebook->api("/page_id?fields=access_token");  try {     $ret_obj = $facebook->api(         '/page_id/feed',          'post',         array (             'link' => 'http://www.example.com/',             'message' => 'this test',             'access_token'  => $page_info['access_token']         )     ); } catch(facebookapiexception $e) {     $login_url = $facebook->getloginurl(array(         'scope' => 'publish_stream'     ));     print_r($e->gettype());     print_r($e->getmessage()); } 

error:

fatal error: uncaught oauthexception: (#100) tried accessing nonexisting field (access_token) on node type (user) thrown in /home/malwatal/public_html/basic/lib/base_facebook.php on line 1028

now it's time use facebook v5 sdk

$fb = new facebook\facebook([   'app_id' => 'app_id',   'app_secret' => 'app_secret',   'default_graph_version' => 'v2.8',   ]);              // facebook auto post  $params = array(   "message" => "$title in $merchant   $short",   "link" => "http://pickmyoffers.com/",   "picture" => "http://pickmyoffers.com/images/searched/flipkart.png",   "name" => "www.pickmyoffers.com",   "caption" => "www.pickmyoffers.com",   "description" => "submit coupon , earn money through pickmyoffers.com | deals,coupons , offers." );             $post = $fb->post('/page_id/feed',$params, $access_token);             $post = $post->getgraphnode()->asarray();  } 

hope it's help


Comments

Post a Comment

Popular posts from this blog

github - Git errors while pushing -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

Unity3d perpendicular vector3 -