Monday, September 22, 2014

get facebook friends list using php api

Graph API Reference /{user-id}/friends

A person's friends.

Reading

/* PHP SDK v4.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/me/friends'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

Permissions

  • A user access token with user_friends permission is required to view the current person's friends.
  • This will only return any friends who have used (via Facebook Login) the app making the request.
  • If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person.

Modifiers

You can append another person's id to the edge in order to determine whether that person is friends with the root node user:
/* PHP SDK v4.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{user-id-a}/friends/{user-id-b}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
If user-a is friends with user-b in the above request, the response will contain the User object for user-b. If they are not friends, it will return an empty dataset.

Fields

An array of User objects representing the person's friends with this additional field:
NameDescriptionType
summaryAn object containing summary info about this edge.object

Publishing

You can't publish using this edge.

Deleting

You can't delete using this edge.

Updating

You can't update using this edge.

No comments:

Post a Comment