-5

I am getting name and id but not more informations about friends.

<?php
    $friends = $facebook->api('me/friends');

    //print_r($friends['data']);
    print_r("Number of Friends: ". count($friends['data']));

    foreach ($friends['data'] as $key=>$listOfFriends) 
    {
       echo "<br/>".$key." ".$listOfFriends['name']."<img src='https://graph.facebook.com/".$listOfFriends['id']."/picture' width='50' height='50' title='".$listOfFriends['name']."' />";     
    }
?>
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
Shaukat Ali
  • 13
  • 3
  • 9

3 Answers3

0

From the Facebook docs:

"Likewise, to protect the privacy of users who have not explicitly authorized your application, your application will only be able to access the basic profile information about a user's friends, like their names and profile pictures. If your application needs to access other data about a user's friends to enable social functionality, you will need to request some of the special friends permissions listed below."

Paul Dessert
  • 6,363
  • 8
  • 47
  • 74
  • thanks for the answer. but still i am confused how to do it.. because i have add permissions to app to access friends emails from Configuring Permissions in application manager.. – Shaukat Ali Sep 05 '13 at 06:17
0

You cannot get the email address of your friends...Everything depends on their Privacy Settings.

If they have allowed to let see friends or other users to view their email address then you can retrive, otherwise NOT.

Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
0

You can, but you have to ask the user for the specific email permissions.

"A user's email is a protected property and access to that information must be specifically requested by the app and granted by the user."

Here is the link https://developers.facebook.com/docs/reference/login/email-permissions/

UPDATE:

useing Facebook Javascript SDK, on client side, you can use this code to ask for email permissions:

FB.login(function(response) { // Asking for email permission.
    // After getting the response, check if the user has granted the permission or not.
    FB.api({ method: 'fql.query', query: 'SELECT email FROM permissions WHERE uid = ' + UserID}, function(resp) {
          if(resp[0]['email'] == '1')
                ; // Permission given.
          else
                ; // Permission not given.
     });
}, {scope: 'email'});
Ganesh Jadhav
  • 2,830
  • 1
  • 20
  • 32