Getit

[insert_php]
$fb = new Facebook\Facebook([
‘app_id’ => ‘{254153565394259}’,
‘app_secret’ => ‘{3df8e866911aa833e54428758aebd045}’,
‘default_graph_version’ => ‘v3.0’,
]);

try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get(‘/me?fields=id,name’, ‘{access-token}’);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo ‘Graph returned an error: ‘ . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo ‘Facebook SDK returned an error: ‘ . $e->getMessage();
exit;
}

$user = $response->getGraphUser();

echo ‘Name: ‘ . $user[‘name’];
// OR
// echo ‘Name: ‘ . $user->getName();
[/insert_php]

Geef een reactie

Loading...