I have an application that uses the old REST API call Friends.getAppUsers
to get the list of friends for the current user that have authorized my application.
Old REST API:
$facebook->api_client->friends_getAppUsers();
New Graph API:
$facebook->api(array('method' => 'friends.getAppUsers'));
Using restFB, I did the following (thanks Igy / Alex for the guidance). Note that Facebook returns an array of friend IDs with "installed"=true if the user is installed (as can be seen here).
First extend the User class, adding an installed
field:
import com.restfb.Facebook;
import com.restfb.types.User;
public class InstalledUser extends User {
@Facebook
private boolean installed;
public InstalledUser() {
}
public boolean getInsatlled() {
return installed;
}
}
Next, using the DefaultFacebookClient:
FacebookClient facebook = new DefaultFacebookClient(pFacebookAccessToken);
Connection<InstalledUser> installedFacebookUsers = facebook.fetchConnection("/" + pFacebookId + "/friends", InstalledUser.class, Parameter.with("fields", "installed"));
for (List<InstalledUser> friends : installedFacebookUsers) {
for (InstalledUser friend : friends) {
if (friend.getInsatlled()) {
// Add friend.getId() to a list of ID, or whatever
}
}
}