Google trends Public Holidays Coupon Code Code Compiler

Auto Post On Facebook Using PHP

Nov 15, 2019

I will show you, how to post automatically post on Facebook page using PHP Facebook Graph API. First one we have to create Facebook App go to and follow the instructions. and get your Access Token and secret key, also need a Facebook PHP SDK to post on Facebook.

define('facebook_app_id', 'XXXXXXXXXXXXXXXXXXXXXXXXX');
define('facebook_app_secret', 'XXXXXXXXXXXXXXXXXXXXXXXXX');
define('facebook_graph_version', 'v2.6');


$fb = new Facebook\Facebook([
	'app_id' => facebook_app_id,
	'app_secret' => facebook_app_secret,
	'default_graph_version' => facebook_graph_version,

	$linkData = [
		'link' => '',
		'message' => 'hii',
		'tags' => '#php'
	$pageAccessToken = '';

	try {
		$response = $fb->post('/me/feed', $linkData, $pageAccessToken);
	} catch (Facebook\Exceptions\FacebookResponseException $e) {
		echo 'Graph returned an error: ' . $e->getMessage();
	} catch (Facebook\Exceptions\FacebookSDKException $e) {
		echo 'Facebook SDK returned an error: ' . $e->getMessage();

Copyright 2024. All rights are reserved