0

我正在尝试参加一个 facebook 用户参加一个活动,

Request.executePostRequestAsync(...)

但服务器总是返回以下内容:

{Response:  responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"FACEBOOK_NON_JSON_RESULT":false}}, error: null, isFromCache:false}

身份验证有效,我可以获取用户信息等...我尝试将我的链接与Graph API Explorer链接,它在那里工作,所以我的代码应该有问题。我还检查了我的权限,他们没问题。如果有人可以帮助我,我会很高兴,这是我的代码:

List<String> permissions = new ArrayList<String>();
permissions.add("rsvp_event");

private void attendToEvent(final String eventID){
    Session.openActiveSession(MainActivity.this, true, new Session.StatusCallback() {

        @Override
        public void call(Session session, SessionState state, Exception exception) {

            Session actSession = Session.getActiveSession();
            if (!hasRSVPEventPermission() && actSession.isOpened()) {
                actSession.requestNewPublishPermissions(new Session.NewPermissionsRequest(MainActivity.this, permissions));
            }

            String accessToken = actSession.getAccessToken();
            String path = new String("https://graph.facebook.com/"+eventID+"/attending");
            if(session != null && session.isOpened()){
                JSONObject jo = new JSONObject();
                final GraphObject go = GraphObject.Factory.create(jo);
                Request.executePostRequestAsync(session, path, go, new Request.Callback() {
                //Request.executeGraphPathRequestAsync(session, path, new Request.Callback() {

                    @Override
                    public void onCompleted(Response response) {
                        System.out.println(response.toString());
                        showAttendResult(response.getGraphObject(), response.getError());
                    }
                });
            }
        }
    });
}

private boolean hasRSVPEventPermission() {
    Session session = Session.getActiveSession();
    return session != null && session.getPermissions().contains("rsvp_event");
} 
4

1 回答 1

1

我发现了!问题是,而不是这条路径:

String path = new String("https://graph.facebook.com/"+eventID+"/attending");

Graph API 期望这样:

String path = new String(eventID+"/attending");

所以没有“ http://graph.facebook.com/ ”!

于 2013-05-07T18:05:56.387 回答