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 question here but there are no solution to solve this problem.

I tried both Graph API and FQL and the behavior was similar. It success 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 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.

I want to share this information with anyone who are facing the same problem and check if changing the App ID (to get the valid access_token) will solve your case.

Answers


Access token returned by Facebook server is valid only for a particular period of time. After which u need to refresh your access token, which is a tedious job. So, in order to avoid this & maintain your token, u need to add the permission "offline_access" to your permission list. This is the approach used by almost FaceBook related apps.


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.


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 params through Bundle.


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.


Need Your Help

What does 'chrome' mean?

javascript firefox firefox-addon terminology xul

content: A browser for content. The content that is loaded inside the browser is not allowed to access the chrome above it.

Why override operator()?

c++ boost operator-overloading functor function-call-operator

In the Boost Signals library, they are overloading the () operator.