// require Facebook PHP SDK
// see: https://developers.facebook.com/docs/php/gettingstarted/

//https://github.com/facebookarchive/facebook-php-sdk/tree/master/src

require_once “base_facebook.php”;
require_once “facebook.php”;

$config = array();
$config[‘appId’] = ‘144929XXXXX4907’;
$config[‘secret’] = ‘385120b56eXXXXXXXXX91c61c4063’;
$config[‘fileUpload’] = false; // optional
$config[‘scope’] = ’email,publish_actions,publish_pages’;

$fb = new Facebook($config);

$accessToken = $fb->getAccessToken();

// define your POST parameters
$params = array(
“access_token” => $accessToken, // see: https://developers.facebook.com/docs/facebook-login/access-tokens/
“message” => “Here is a blog post about auto posting on Facebook using PHP”,
//”link” => “#”,
// “picture” => “http://webetutorial.com/logo.png”,
// “name” => “How to Auto Post on Facebook with PHP”,
//”caption” => “www.webetutorial.com”,
// “description” => “Automatically post on Facebook with PHP using Facebook PHP SDK.”
);

// post to Facebook
// see: https://developers.facebook.com/docs/reference/php/facebook-api/
try {
$ret = $fb->api(‘/me/feed’, ‘POST’, $params);
echo ‘Successfully posted to Facebook’;
} catch(Exception $e) {
echo $e->getMessage();
}

Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.