6

I'm trying to convert friend pages into fan pages (most businesses have created friend pages by mistake) and am trying to email everyone on a friend list about the move.

I've tried

  1. FQL "SELECT email FROM user WHERE uid=xxxx"
  2. Creating groups (not good for 5000 friend pages)
  3. Restfb: Connection myFriends = facebookClient.fetchConnection("me/friends", User.class) etc;

The FQL and RestFB methods are both returning nada, group email method is just plain messy.

Is this a security feature or can this data ever by returned for my purpose?

Cheers

1
  • Crazy question, but do each of these profiles explicitly give applications access to the email address? Facebook's new policies force the "friends" to opt in to giving applications access to their email addresses. Aug 27, 2011 at 12:36

4 Answers 4

2

to access user's private informations like email,posts etc you should have the permission to access those details .for more details visit https://developers.facebook.com/docs/reference/api/permissions/

1

If you are using restfb (Facebook graph API and old REST API client wriiten in Java), and you want to access all friend list after Oauth authentication, you can use following method to access the friends list and facebook id's,

public List<ArrayList> findFacebookFriendsUsingRest(String facebookAccessToken){

    List<ArrayList> myFacebookFriendList= new ArrayList();
    final FacebookClient facebookClient;
    facebookClient = new DefaultFacebookClient(facebookAccessToken);
    User user = facebookClient.fetchObject("me", User.class);
    String userName = user.getFirstName();

    if (userName == null){
        userName = user.getLastName();
    }

    String userEmail = user.getEmail();
    com.restfb.Connection<User> myFriends = facebookClient.fetchConnection("me/friends", User.class);

    System.out.println("Count of my friends: " + myFriends.getData().size());

    for(User friend: myFriends.getData()){
        System.out.println("Friends id and name: "+friend.getId()+" , "+friend.getName());      
        myFacebookFriendList.add(friend.getName());
    }

    System.out.println("All Friends : "+myFacebookFriendList);
}
0

Facebook does not provide user, unless the user authorizes your application to access it. It's on account of security and user privacy, imagine how terrible it would be if everybody could have at her disposal all FB user's email addresses.

4
  • But as they are "accepted" friends from both sides, I can see their email addresses through the site. Just seems strange that I can do it manually but not through the api.
    – mabeloo52
    May 14, 2010 at 19:38
  • thanks but I think that refers to applications. I'm just using an access token generated by my profile. I can return a list of friends and their unique Ids, problem is everything else is blank. Example: User[about=null birthday=null education=[] email=null firstName=null id=12345678 interestedIn=[] lastName=null link=null metadata=null name=Tom Jones picture=null relationshipStatus=null religion=null timezone=null type=null updatedTime=null verified=null website=null work=[]]
    – mabeloo52
    May 14, 2010 at 19:56
  • Ok, what I have done is get the unique IDs, and then use them within the FQL to fetch the info accordingly, for example, assuming that you have in a $IDS variable all the unique IDs glued together separated by commas 'SELECT uid, first_name, last_name, hometown_location, pic_square, activities, interests, work_history FROM user WHERE uid IN (' . $IDS . ') ORDER BY last_name';
    – falomir
    May 14, 2010 at 20:12
  • Still the same String query = "SELECT uid, first_name, last_name, hometown_location, pic_square, activities, interests, work_history, email FROM user WHERE uid=" + currentUser.getId(); List<User> users = facebookClient.executeQuery(query, User.class); Thats what I'm running but getting a load of nulls. Will update if anything pops up. Thanks
    – mabeloo52
    May 14, 2010 at 21:18
0
Connection<User> myFriends = facebookClient.fetchConnection("me/friends", User.class ,Parameter.with("fields", "id, name, picture, email"));

You can specify any of the properties listed under http://developers.facebook.com/docs/reference/api/user

The only thing is that FB does not seam to return the friends email.. I'm using restFb 1.5.3

1
  • 1
    Yeah it looks like email just isn't available through the API. This is a bit strange since a few companies are scraping the site to get the data yet going about it the legal way doesn't work.
    – mabeloo52
    Oct 6, 2010 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.