1

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 SampleRequestListener());

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)?

Rich Schuler
  • 41,814
  • 6
  • 72
  • 59
cr_az
  • 453
  • 1
  • 5
  • 16

3 Answers3

7

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.

Adil Soomro
  • 37,609
  • 9
  • 103
  • 153
om252345
  • 2,395
  • 4
  • 29
  • 31
0

Check this answer in order to know how to get Facebook friend list and who of these friends have installed your app.

Community
  • 1
  • 1
JPMagalhaes
  • 3,611
  • 1
  • 25
  • 26
0

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.

Bartek
  • 1,059
  • 6
  • 18
  • Hi, thank you for suggestion. I tried to call ""me/friends/Friend_ID" - APi returns just list of all friends (id:name). – cr_az Jan 08 '11 at 09:00
  • First you need to get the IDs so you need to call `/me/friends`. Then you can loop over all friends and for each of them call just `/Friend_ID` (without `me`). Hope this helps – Bartek Jan 08 '11 at 10:51