Question

How do I get facebook realtime updates with android .Basically everytime the user's friendlist changes I need to update the count.I used the code below but I get error msg :

{This method must be called with an app access_token.}, isFromCache:false}

I really appreciate any help.Thanks in Advance.

code:

Bundle params = new Bundle();
params.putString("object", "user");
params.putString("callback_url", "http://example.com/callback/update.php");
params.putString("fields", "friends");
params.putString("verify_token", "1234");
/* make the API call */
new Request(
    session,
    "/12345/subscriptions",
    params,
    HttpMethod.POST,
    new Request.Callback() {
        public void onCompleted(Response response) {
            /* handle the result */
        }
    }
).executeAsync();

Note: session =fb.getsession();

Was it helpful?

Solution

This error:

"This method must be called with an app access_token."

is quite straight-forward. You just need to make this API call with an App access token, instead of a normal access token (user token). To use it with your call simply add another parameter: access_token and make the call.

The App Access token is nothing but, APP_ID|APP_SECRET, or you can make the call (ref.)-

GET /oauth/access_token?
      client_id={app-id}
      &client_secret={app-secret}
      &grant_type=client_credentials

But beware, its not recommended to expose app access token on the client side, since its like a password of your app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top