P
P
Proger59132021-05-07 19:08:58
Facebook
Proger5913, 2021-05-07 19:08:58

How to get information about a user using the Facebook API?

Hello dear. Such a thing, you need to get information about the user. We will assume that we need a method to which I send a link to the user's FB, and in response he gives me information about him, by type of name, date of birth, link to the profile picture)

VK example:

$info = file_get_contents('https://api.vk.com/method/users.get?user_ids='.$userID.'&fields=photo_max,bdate,city&v=5.130&lang=ru&access_token='.$VK_TOKEN);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sl0, 2021-05-07
@sl0

one.

/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{person-id}/',
    '{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;
}
$graphNode = $response->getGraphNode();
/* handle the result */

https://developers.facebook.com/docs/graph-api/ref...
2. https://developers.facebook.com/docs/messenger-pla...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question