Paging does not work and maybe I found the cause
Asked Answered
W

5

44

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?

Winifred answered 15/2, 2012 at 7:49 Comment(2)
Can you provide some sample code that you're using at the minute? It's not really clear what you're doing.Valediction
What permissions does your app request?Laminated
C
1

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.

Cotter answered 5/4, 2012 at 20:53 Comment(0)
G
1

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.

Glomeration answered 6/5, 2012 at 5:20 Comment(0)
O
1

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

Overwinter answered 4/2, 2022 at 21:16 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Zingg
L
0

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.

Lag answered 2/4, 2012 at 11:15 Comment(0)
D
0

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.

Delphine answered 19/7, 2012 at 7:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.