Android facebook获取新权限错误

时间:2015-01-19 12:07:49

标签: android facebook-android-sdk

我已经按照教程从我的Android应用程序登录facebook。一切正常。现在,在第二个片段上,我希望获得发布到facebook故事的权限。这是我的代码:

   private void publishStory() {
    session=Session.getActiveSession();
    if (session != null && session.isOpened()){

        // Check for publish permissions
        List<String> permissions = Session.getActiveSession().getPermissions();
        Log.e("permisions",permissions.toString());
        if (!isSubsetOf(PERMISSIONS, permissions)) {
            pendingPublishReauthorization = true;
            Session.NewPermissionsRequest newPermissionsRequest = new Session
                    .NewPermissionsRequest(this, PERMISSIONS);
            session.requestNewPublishPermissions(newPermissionsRequest);

            return;

        }

        Bundle postParams = new Bundle();
        postParams.putString("name", "FACEBOOK GIA TO ANDROID");
        postParams.putString("caption", "Build great social APPS BUGGY AND SHITTY");
        postParams.putString("description", "EINAI GIA TON POUTSO");
        postParams.putString("link", "https://developers.facebook.com/android");
        postParams.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");

        Request.Callback callback= new Request.Callback() {
            public void onCompleted(Response response) {
                JSONObject graphResponse = response
                        .getGraphObject()
                        .getInnerJSONObject();
                String postId = null;
                try {
                    postId = graphResponse.getString("id");
                } catch (JSONException e) {
                    Log.i("TAG",
                            "JSON error "+ e.getMessage());
                }
                FacebookRequestError error = response.getError();
                if (error != null) {
                    Toast.makeText(getActivity()
                                    .getApplicationContext(),
                            error.getErrorMessage(),
                            Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getActivity()
                                    .getApplicationContext(),
                            postId,
                            Toast.LENGTH_LONG).show();
                }
            }
        };

        Request request = new Request(session, "me/feed", postParams,
                HttpMethod.POST, callback);

        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
    }

}
}

我第一次运行这个片段它要求我给予权限,一切正常,但当我回到应用程序时,没有帖子。 每次我运行应用程序时都会说我只有用户的基本信息并且喜欢权限,但是当我从PC上登录facebook时,我可以看到帖子和基本权限。

0 个答案:

没有答案