0

Hello friends i need to get user information from facebook i am using code

String about_me=facebook.request("me");

but this is showing error :---

{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}

can any body tell me how to resolve this ????

user1249134
  • 165
  • 1
  • 1
  • 7

1 Answers1

0

that error means that your Facebook object does not have a valid access token. try something like this to see what your access token and its associated expiration time is.

Log.d("myapp", "access token = " + facebook.getAccessToken());
Log.d("myapp", "expiration = " + facebook.getAccessExpires());
Log.d("myapp", "expiration datetime = " + (new Date(facebook.getAccessExpires())).toString());
Log.d("myapp", "is session valid? " + facebook.isSessionValid());

it is your job to check whether you (the user) has an access token and if it is still valid. if not then you must open up the dialog to proceed with authentication.

facebook.authorize(Activity activity, String[] permissions, DialogListener);

the newer android facebook API is supposed to work with single sign on (SSO). meaning, if a user already has "THE" official facebook app installed and is logged into that official app on the device, then the user does not have to re-authenticate.

otherwise, an (ugly) dialog shows up where the user has to enter in their credentials (which is just a web browser embedded in the dialog).

Jane Wayne
  • 535
  • 9
  • 21
  • hello jane i am getting access token=null – user1249134 Mar 08 '12 at 04:54
  • expiration =o ,session is valid =false – user1249134 Mar 08 '12 at 04:55
  • can u tell me the right way to implement it if u have any link so that would be easy for me ,as i am new in this .. – user1249134 Mar 08 '12 at 04:56
  • yes that is your problem right there. your access token is invalid, thus the message above. go here for the official facebook sdk for android: http://developers.facebook.com/blog/post/385/ – Jane Wayne Mar 08 '12 at 05:18
  • a fully working dummy example that you have to stare at over and over (which is what i did, but after a while, it didn't seem so bad) is here: https://github.com/facebook/facebook-android-sdk/tree/master/examples/simple – Jane Wayne Mar 08 '12 at 05:20
  • Thank-you every one by this i am able to get login page in my application and also i am able to get the information of user of login but when i am sending this information to my server response is not coming...can any body tell me where might be the problem ... – user1249134 Mar 08 '12 at 14:38
  • post some code. i have no idea what you are trying to say. are you saying you can get data from facebook's graph API but can't send that data to your server? if so, that's probably another post. – Jane Wayne Mar 08 '12 at 15:02
  • yes man i resolved this the issue was my server will provide access in my android application if user has fb account so now its working i was passing wrong parameters ...THANKS FOR UR SUPPORT ,that was very helpfull .. – user1249134 Mar 09 '12 at 06:02
  • I am stuck on the same problem, but I do have a correct token! I do not have offline_connection though but still I get a 2 hour token that can be extended at my will. – MLProgrammer-CiM May 15 '12 at 11:31