I’m writting app integrated with facebook. I want to post to wall without post dialog. I try to use code from this answer, but I got an error
{"error":
{"message":"An active access token must be used to query information about the current user.",
"type":"OAuthException",
"code":2500
}
}
I login user with this code
public void authorize() {
mFacebook.authorize(mActivity, new String[] { "publish_stream" }, new DialogListener() {
@Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", mFacebook.getAccessToken());
editor.putLong("access_expires", mFacebook.getAccessExpires());
editor.commit();
mLoginStateView.setImageResource(mAuthorizedDrawableRes);
}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {}
});
}
Please, explain me what am I doing wrong?
[ADDED]
If I try to post with mFacebook.dialog(currentActivity, "stream.publish", params, new UpdateStatusListener()); it works. Please, help me!
Oh, I’ve done it. But it looks like a bug or magic…
LogCat after authorize method (Facebook’s log is enabled)
But then I try post with
Function request from Facebook.java :
I see in debugger, that Facebook’s function
isSessionValid()returnsfalseandmAccessToken = null. I don’t know why it is so, and why it returnstruesometimes afterwards (yes, I understand that it is impossible). Explaine me, please, if you know.This code solved my problem (it just re-sets access token)