If your are a web developer are Social page manager Auto posting to your facebook page is important. In this post I will Show you how to auto post to your fb page in PHP using curl.
Get Page access token
What you need for Auto posting to facebook page is Page access token. Page access token that Graph API Explorer generate for you is short live and will expire in 60 seconds or 60 days. In my Previous Blog Post I teach How to get Non expiring Facebook Page access Token. Get your never expiring facebook page access token from link.
PHP Code for Auto Posting to Facebook Page
Requirements: You only need is your Page access token for auto posting.
PHP code for auto posting to facebook page with curl method is:
$page_access_token = 'your page access token';
$page_id = 'your page id';
$data['link'] = "https://www.ntafzal.com";
$data['message'] = "Your Post Title";
//$data['picture'] = "http://vu.theafzal.com/images/afzal.jpg";
$data['access_token'] = $page_access_token;
$post_url = 'https://graph.facebook.com/v2.11/'.$page_id.'/feed';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
echo "$return";
curl_close($ch);
Picture is optional it only works if you have verified your domain on facebook. Otherwise leave it and Facebook will fetch image from your post as a thumbnail.
Add Your Comment
Comments
No comments found.