简体   繁体   中英

How to look up a User on Facebook's Android SDK (using Graph API or whatever) with a User ID?

I have a list of User ids as input to my android program, and would like to look them up on facebook to display names, pics, etc. I see a lot of tutorials on how to get the current users profile, and how to get that users friends. I even see tutorials on how to search for users by name (passing id does nothing). Is there no way to say "Give me the profile this id belongs to"?

You should not use the com.facebook.android.Facebook class anymore as its use is deprecated.

If you're using version 3.0 of the SDK, you can use the Request.newGraphPathRequest method, and just pass in the user id as the graphPath. Then in the callback, you can call response.getGraphObjectAs(GraphUser.class), which gives you a GraphUser that you can get the name from.

如果您具有授权的facebook对象,则可以使用request方法获取更多信息:

String jsonstring = facebook.request(id);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM