Auto Post on Facebook with PHP script

<?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 your 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 your POST parameters (replace with your own values) $params = array( "access_token" => "YOUR_ACCESS_TOKEN", // see: https://developers.facebook.com/docs/facebook-login/access-tokens/ "message" => "Here is a blog post about 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 to Auto Post on Facebook with PHP", "caption" => "www.pontikis.net", "description" => "Automatically post on Facebook with PHP using Facebook PHP SDK. How to create a Facebook app. Obtain and extend Facebook access tokens. Cron automation." ); // post to Facebook // see: https://developers.facebook.com/docs/reference/php/facebook-api/ try { $ret = $fb->api('/YOUR_FACEBOOK_ID/feed', 'POST', $params); echo 'Successfully posted to Facebook'; } catch(Exception $e) { echo $e->getMessage(); } ?>
Information included in comment

7 Responses

Where i can download facebook.php file?
@Heider Kumar https://github.com/facebookarchive/wordpress/tree/master/includes/facebook-php-sdk you can download from here. If need anything else please let me know.
pls i need the file
and what am i going put to the
$ret = $fb->api('/YOUR_FACEBOOK_ID/feed', 'POST', $params);
@Adedokun Adekola https://github.com/facebookarchive/wordpress/tree/master/includes/facebook-php-sdk you can download from here.

Also you can follow https://developers.facebook.com/docs/php/gettingstarted/ for getting more instruction.

If need anything else please let me know.
hi i m nishant and using your script but giving an error " Class 'Facebook' not found".So didnt get what happened please help me out.
@David Craft Hi David

You must download the Facebook PHP Graph SDK - Here's the Github link https://github.com/facebook/php-graph-sdk
I want to built something similar to https://codecanyon.net/item/king-poster-facebook-multi-group-page-auto-post-php-script/13302046

I want to buy source code if not free, contact me on skyp :
Dialtrackers@gmail.com

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.