2

直到昨天,我的应用程序才将提要故事发布到 Facebook 上。

现在它停止工作并在回调中发送此错误:

“com.facebook.FacebookException:无法构造请求正文”

这来自:

    response.getError();

奇怪的是,来自 facebook 的示例应用程序停止工作,现在报告同样的错误,我很确定我没有更改任何内容。

这是示例应用程序功能:

    private void publishStory() {
    Session session = Session.getActiveSession();

    if (session != null){

        // 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", "Facebook SDK for Android");
        postParams.putString("caption", "Build great social apps and get more installs.");
        postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
        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) {
                FacebookRequestError error = response.getError();
                 if (error != null) {
                        Toast.makeText(getApplicationContext(),
                             error.getErrorMessage(),
                             Toast.LENGTH_SHORT).show();
                        return;
                 } 


                JSONObject graphResponse = response
                                           .getGraphObject()
                                           .getInnerJSONObject();
                String postId = null;
                try {
                    postId = graphResponse.getString("id");
                } catch (JSONException e) {
                    Log.i("publishStory",
                        "JSON error "+ e.getMessage());
                }

                Toast.makeText(getApplicationContext(), postId,Toast.LENGTH_LONG).show();
            }
        };

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

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

}

任何人都可以帮忙吗!先感谢您。

4

1 回答 1

1

现在它可以工作了......我在晚上关闭了我的电脑和 Eclipse,现在重新启动

我猜这是编译器中的一些错误。

于 2013-07-05T11:28:10.400 回答