PHP code example of abdulbaquee / facebook-graph-sdk

1. Go to this page and download the library: Download abdulbaquee/facebook-graph-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/ */

    

abdulbaquee / facebook-graph-sdk example snippets


if (isset($_GET['code'])) {
    $accessToken = $oauth->getAccessTokenFromCode($_GET['code']);
    echo 'Access Token: ' . $accessToken;
}

$client = new BaseClient($accessToken);
$response = $client->get('/me?fields=id,name,email');
$user = $response->getBody();

echo 'ID: ' . $user['id'];
echo 'Name: ' . $user['name'];
echo 'Email: ' . $user['email'];

$batch = [
    $client->createRequest('GET', '/me?fields=id,name'),
    $client->createRequest('GET', '/me/friends'),
];

$batchResponse = $client->sendBatchRequest($batch);

foreach ($batchResponse->getResponses() as $response) {
    print_r($response->getBody());
}