Php to post on facebook fan page not working -


all,

i'm trying post on facebook fan page directly below php code. posting "post on pages" , shown @ side. have wordpress plugin post directly facebook fan page , want replicate same. please check , let me know on update on this.

<?php // require facebook php sdk // see: https://developers.facebook.com/docs/php/gettingstarted/ require_once("/your_path_to/facebook_php_sdk/facebook.php");  // initialize facebook class using own facebook app credentials // see: https://developers.facebook.com/docs/php/gettingstarted/#install $config = array(); $config['appid'] = 'your_app_id'; $config['secret'] = 'your_app_secret'; $config['fileupload'] = false; // optional  $fb = new facebook($config);  // define post parameters (replace own values) $params = array(   "access_token" => "your_access_token", // see: https://developers.facebook.com/docs/facebook-login/access-tokens/   "message" => "here blog post auto posting on facebook using php #php #facebook",   "link" => "http://www.pontikis.net/blog/auto_post_on_facebook_with_php",   "picture" => "http://i.imgur.com/lhkosih.png",   "name" => "how auto post on facebook php",   "caption" => "www.pontikis.net",   "description" => "automatically post on facebook php using facebook php sdk. how create facebook app. obtain , extend facebook access tokens. cron automation." );  // post facebook // see: https://developers.facebook.com/docs/reference/php/facebook-api/ try {   $ret = $fb->api('/your_facebook_page_id/feed', 'post', $params);   echo 'successfully posted facebook'; } catch(exception $e) {   echo $e->getmessage(); } ?> 

if posting, not "as page" "as user", need use page token instead of user token.

information on how create page token:

get user token > extend user token > call /me/accounts extended page token

you must use page token in order post "as page" , should use "extended page access token" valid forever.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -