Frage

I'm developing a Facebook app, one of the things that I need is: a list with two columns - name and number of mutual friends. I want this for every friend I have.

I already saw the documentation and check that I can get what I want by this url (by http get request): https://graph.facebook.com/me/mutualfriends/FRIENDID.

But I don't known how to get the data from this url, I tried the http_get keyword unsucefully. I read somewhere to use curl instead. I'm a little confused about this.

Anyone knows how to do this in code, I just want to know how to manipulate the data inside the url.

Cheers

Thanks mariachi, that was i wanted. I made a loop to get all my friends and counted all mutual friends for each friend. However it tooks too long that I end with this error Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\app\php-sdk\src\base_facebook.php on line 809 and it hust print the first 15 friends.

Anyone knows a solution to this, maybe a faster way to get the number of mutual friends.

War es hilfreich?

Lösung

(I am assuming that you mean manipulating the data that is returned when you make that call).

This is the data returned in JSON when you make that call:

{
"data": [
  {
  "name": "FRIEND_NAME", 
  "id": "FRIEND_ID"
  }, 
  {
  "name": "FRIEND_NAME", 
  "id": "FRIEND_ID"
  }, 
  {
  "name": "FRIEND_NAME", 
  "id": "FRIEND_ID"
  }, 
  {
  "name": "FRIEND_NAME", 
  "id": "FRIEND_ID"
  }
 ],
}

So you can access the name as

$var_name=$returned_data[data][0][name];
$var_id=$returned_data[data][0][id];

try the mutual friend call on Graph Api Explorer to get a better understanding of the data returned

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top