Post to Facebook Wall from Web Application using PHP

Facebook is the most popular social media network. Post to Facebook wall is useful when you want to post dynamic content to Facebook from the web application. In this tutorial, we will explain how to post activity on Facebook wall using PHP and Facebook API. This is a very simple example, you can just copy paste and change according to your requirement.
First, follow the below steps to create a Facebook App Account and generate App ID & App Secret Key.
  • Go to the Facebook for Developers page and Login your Facebook Account.
  • Right corner of the top navigation, click the My Apps link and select Create New App.
  • Enter the Display Name and Contact Email.
  • Click the Create App ID button.
  • The new App will be created and redirected to the Facebook App Dashboard.
  • You can Download the latest version of the SDK
Before started to implement the Post on Facebook wall using PHP, look files structure:
  • post-to-facebook-wall-using-php-sdk
    • facebook-php-graph-sdk
    • index.php
    • function.php
Create Facebook API Configuration file named configuration.php
  • The configuration.php file is used to configure Facebook SDK and connect to Facebook Graph API.
  • Access token must have the publish_actions permission to post on Facebook wall.
Submit Post to Facebook Wall file named index.php
  • Include the configuration.php file to connect Facebook API & get the access token.