I`m working on small Android application, trying to add Facebook support.
Main problem: I can get only basic info regarding user`s friends (id, name). List of app permissions (offline_access is here just for test, will be removed soon):
String[] sPermissions = { "friends_about_me"
, "friends_birthday"
, "friends_location"
, "friends_website"
, "offline_access" };
mLoginButton.init(this, mFacebook, sPermissions);
Following request works fine - returns a list of id:name pairs,
mAsyncRunner.request("me/friends", new SampleRequestListener());
but if I change it in order to get more info
mAsyncRunner.request("me/friends?fields=id,name,birthday,hometown", new Sample开发者_开发技巧RequestListener());
server returns error "An active access token must be used to query information about the current user." I tested these Graph API requests using browser - both of them work as expected.
Small remark: I`m using default debug cetificate to sign apllication and add it hash as facebook application hash according to Facebook instruction:
Register your application's Android key hash. This is used by Facebook to ensure that another app can't impersonate your app when talking to the Facebook Android app.
Generate the key hash:
keytool -exportcert -alias [alias] -keystore [keystore] | openssl sha1 -binary | openssl base64 In the Facebook developer settings, go to the Mobile and Devices tab.
In the Android section, enter the key hash in the Key Hash field.
Maybe there is another way to get user`s frineds info (bday, location, gender and so on)?
Use
mFacebook.request(graphpath, bundle);
method,
Bundle
will have parameters which will be like this
graphpath = "me/friends"
bundle.putString("fields","birthday");
and call above request method, it will give you birthdays but you have to add friends_birthday
permission.
when you call /me/friends
in Graph API all it returns is friends' IDs and names. If you want to get more information about friends you can call /Friend_ID
afterwards.
Check this answer in order to know how to get Facebook friend list and who of these friends have installed your app.
精彩评论