android:登录后facebook分享不工作Access_token为空

时间:2014-04-22 09:01:48

标签: android facebook facebook-access-token facebook-sharer

大家都在公开的Facebook墙上发布自定义数据。这在没有安装Facebook应用程序的设备上运行正常。但是在安装了facebook的设备上,access_token为空,我无法共享文本。

 new Session(UserShareActivity.this).openForPublish(new Session.OpenRequest(UserShareActivity.this).setPermissions(PERMISSIONS).setCallback(new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            if (session.isOpened()) {
                Bundle postParams = new Bundle();
                postParams.putString("message", getIntent().getStringExtra("message"));
                postParams.putString("access_token", session.getAccessToken());
                Log.d("pageID", prefs.getString(Strings.pageID, ""));
                Log.d("getAccessToken", "" + session.getAccessToken());
                Request request = new Request(null, prefs.getString(Strings.pageID, "") + "/feed", postParams, HttpMethod.POST, callback);
                RequestAsyncTask newtask = new RequestAsyncTask(request);
                newtask.execute();
            }
        }
    }));
传递回调的

OnActivityResult()方法:

 @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    try{
        Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
    }catch(Exception e){
        e.printStackTrace();
    }
}

0 个答案:

没有答案