PHP code example of thomaswelton / facebook-php-sdk
1. Go to this page and download the library: Download thomaswelton/facebook-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
thomaswelton / facebook-php-sdk example snippets
$facebook = new Facebook\Facebook(array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
$facebook->api('/me/feed/', 'post', array(
'message' => 'I want to display this message on my wall'
));