daoki2
daoki2

Reputation: 441

Paging does not work and maybe I found the cause

I am trying to implement the stream (news feed) paging function to my app, but it does not work as expected. I found many similar questions here but there are no solutions to solve this problem.

I tried both Graph API and FQL and the behavior was similar. It succeeds to get the result one or two times but after that, it fails to get the result (gets the empty JSON array).

Finally, I found this problem depends on access_token. If I just change the source code to use Android SDK Stream Example App ID rather than my own App ID for authentication, it works perfectly.

So, I believe the Facebook server checks the App ID and returns some weird or restricted access_token to my app.

Are there any condition to get the valid access_token? I tried the exact same permissions with Android SDK Stream example app, but it could not solve the problem.

Will changing the App ID (to get the valid access_token) solve the case?

Upvotes: 44

Views: 1249

Answers (5)

AndroidGuy
AndroidGuy

Reputation: 1330

The access token returned by Facebook server is valid only for a particular period of time. After which you need to refresh your access token, which is a tedious job.

So, in order to avoid this and maintain your token, you need to add the permission "offline_access" to your permission list. This is the approach used by almost Facebook-related apps.

Upvotes: 0

Sameer Bhide
Sameer Bhide

Reputation: 171

Use the Facebook SDK for Android. It can be found here. There are getter and setter methods to get and set the access token. The first time you do a single sign-on (SSO), you must save the access token in SharedPreferences and there's no need to reauthenticate again and again.

Just set the access token from your preferences and make a call to the feed dialog. The offline_access permission is to be deprecated. The Facebook SDK for Android does the rest of the work. Just supply sufficient parameters through Bundle.

Upvotes: 1

jlainez
jlainez

Reputation: 11

Try using the SDK on Facebook. Then get the access token.

Upvotes: 1

Anna Billstrom
Anna Billstrom

Reputation: 2492

A couple of things on Android:

  • get right permissions "read_stream"
  • Use the android SDK
  • Check the sample that came w/ android. In the onCreate(), I authenticate Facebook object

    this.facebook.authorize(this, new DialogListener() {....}

  • Test using Facebook's Graph API Explorer.

If you paste in some code I can help you debug further.

Upvotes: 0

studgeek
studgeek

Reputation: 14910

Verify your app has the read_stream permission. Without it you will not get any non-public objects.

There also seems to be some general LIMIT OFFSET issues with FQL and stream. See Facebook FQL stream limit? and http://developers.facebook.com/bugs/303076713093995.

Upvotes: 1

Related Questions