Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook emails always return null through FQL and RestFB

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

like image 478
mabeloo52 Avatar asked May 14 '10 19:05

mabeloo52


2 Answers

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/

like image 64
Soojoo Avatar answered Nov 19 '22 14:11

Soojoo


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);
}
like image 28
Youdhveer Avatar answered Nov 19 '22 15:11

Youdhveer