0

所以新的 facebook 3.0为如何在墙上发帖提供了很好的指南。但是当它不飞时你会怎么做?

我收到以下来自 facebook 的回复:

{Response:  responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 100, errorType: OAuthException, errorMessage: (#100) Missing message or attachment}, isFromCache:false}

这是我的权限更新:

                Session session = ParseFacebookUtils.getSession();
                if(session != null) {

                    List<String> permissions = session.getPermissions();
                    if (!isSubsetOf(PERMISSIONS, permissions)) {
                        Session.NewPermissionsRequest newPermissionsRequest = new Session
                                .NewPermissionsRequest(this, PERMISSIONS);
                        session.requestNewPublishPermissions(newPermissionsRequest);
                        return;
                    }

                    publishStory();
                }

权限具有以下内容:

private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");

这是我的发布代码,其中非常(不完全)是从 facebook 复制粘贴:

private void publishStory() {
    Bundle postParams = new Bundle();
    postParams.putString("name", "Test");
    postParams.putString("caption", "Another Test");
    postParams.putString("description", mEdit.getText().toString());

    Request.Callback callback = new Request.Callback() {
        public void onCompleted(Response response) {
            JSONObject graphResponse = response
                                       .getGraphObject()
                                       .getInnerJSONObject(); //FIXME <-- here we get the error
            String postId = null;
            try {
                postId = graphResponse.getString("id");
            } catch (JSONException e) {
                Log.i(GlobalValues.LOG_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(ParseFacebookUtils.getSession(), "me/feed", postParams, 
                          HttpMethod.POST, callback);

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

非常感谢所有帮助。

编辑

这是我在请求时的权限列表:

[status_update, photo_upload, video_upload, create_note, share_item, publish_stream, publish_actions, basic_info]
4

1 回答 1

1

你检查发布权限了吗?您发布的链接中的代码在发送请求之前检查权限。

    // Check for publish permissions    
    List<String> permissions = session.getPermissions();
    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", "Test");
postParams.putString("caption", "Another Test");
postParams.putString("description", mEdit.getText().toString());
postParams.putString("message", "My message");
于 2013-07-18T14:11:44.720 回答