Алчный account fb connect php. Это правильный способ сделать FB Connect? Регистрация приложения в фб

Facebook is the most popular social media and shares on the Facebook wall are the most used activity by its user. Facebook share option is a common and required feature for every web application. We can easily share the post on Facebook by manually or from the script. In this tutorial, you’ll learn how to post activity on Facebook wall from website using PHP and Facebook API.

Post to Facebook wall is useful when you want to post dynamic content to Facebook from the website. Here we’ll build a simple PHP script to publish Facebook post from website using Facebook PHP SDK. This functionality lets the user submit the post (message, picture, link, text content) on their Facebook timeline from the website using PHP SDK v5.0 and Facebook Graph API .

Before getting started to post to Facebook wall using PHP, take a look at the files and folders structure.

Facebook Apps Creation

To access Facebook API, App ID & App Secret need to be specified on Facebook API call. You need to create a Facebook App for generating App ID & App Secret. If you’re not already created a Facebook app, visit the link below to create and configure a Facebook App from the App Dashboard .

After completing the Facebook App creation and configuration you’ll get the App ID and App secret. Copy this App ID and App Secret of your Facebook App for later use.

Facebook SDK for PHP v5.0

All Facebook PHP SDK files are included in the facebook-php-sdk/ directory, place the facebook-php-sdk/ folder into the root directory. You don’t need to download it separately, Facebook SDK v5 is included in our source code.

Facebook API Configuration (fbConfig.php)

The fbConfig.php file is used to configure Facebook SDK and connect to Facebook Graph API. Specify your Facebook App ID ($appId), App Secret ($appSecret), Callback URL ($redirectURL), and Permissions ($fbPermissions) to connect with Facebook API and working with SDK.

Note that: The access token must have the publish_actions permission to post on Facebook wall.

Note that: You’ll find the App ID and App Secret on your Facebook Apps settings page.

Submit Post to Facebook Wall (index.php)

Include the fbConfig.php file to connect Facebook API and get the access token.

If FB access token ($accessToken) is available, the following will happen.

If FB access token ($accessToken) is not available, the Facebook Login URL will be generated and the user would be redirected to the FB login page.

Google Chrome