Facebook股票回应正在变为零

时间:2014-11-06 13:20:55

标签: android android-facebook

我正在尝试使用以下代码发布facebook:

 Session session = Session.getActiveSession();

    if (session != null) {


        Bundle postParams = new Bundle();
        postParams.putString("name", "Facebook SDK for Android");


        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("error",
                            "JSON error " + e.getMessage());
                }

            }
        };

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

        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
    } else {
        Session.setActiveSession(new Session(this));
    Session.getActiveSession().getActiveSeopenForPublish(new Session.OpenRequest(this)
                .setPermissions(Arrays.asList("publish_stream"))
                .setCallback(new SessionStatusCallback()));
    }

它无效,我在响应response.getGraphObject上获得空指针异常。 请帮忙

0 个答案:

没有答案