Why cant Facebook stop using PHP

Auto Post On Facebook Using PHP

Last Updated - Aug 30, 2019

Tags:- PHPFacebook


In this tutorial we will show you how to post automatically on Facebook using PHP and Facebook Graph API.You just have to create a Facebook App and get your Access Token and need a Facebook PHP SDK to help to post on Facebook.You may also like login with facebook using PHP.




To Post On Facebook Automatically It Takes Only Three Steps:-

  1. Create A Facebook App
  2. Get Facebook Access Token
  3. Make a PHP file and define methods to Post On Facebook


Step 1.Create A Facebook App


Before creating Facebook App you need to download Facebook PHP SDK and it requires PHP 5.2.0 or higher for PHP curl extension.Now we have to create Facebook App go to https://developers.facebook.com/apps and follow the instructions.



Step 2.Get Facebook Access Token


To get Access Token you have to set callback URL for the Facebook app to get the result.Then authorize the app for permissions on https://developers.facebook.com/docs/facebook-login/permissions/v2.2 and then get the Access Token.Make sure renew your Facebook Token After 60 days because Facebook Access token will expires in 60 days.



Step 3.Make a PHP file and define methods to Post On Facebook

We make a PHP file and save it with a name autopost.php


<?php $access_token = Your_Access_Token; $facebookData = array(); $facebookData['consumer_key'] = Your_key; $facebookData['consumer_secret'] = Your_Secret; $title = Post_Title; $targetUrl = Post_URL; $imgUrl = Image_URL; $description = Post_Description; $facebook = new FacebookApi($facebookData); $facebook->share($title, $targetUrl, $imgUrl, $description, $access_token); ?>

After using above code you post will be posted automatically on your Facebook profile automatically.You may also like get facebook like, share and comment using PHP.


Thats all, this is how to Post On Facebook Automatically using PHP.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.