0

我是 Facebook SDK 3 的新手。我想使用 SDK 创建相册。但相册没有创建。我发送了请求,但没有执行回调。

请帮我

public void connectToFacebook(){
    Session session = Session.openActiveSession((Activity)context, true, new StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            Log.v(GlobalVars.TAG, "In Call");
        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(Session.getActiveSession() != null) {
        Session session = Session.getActiveSession();
        Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
        Bundle bundle = new Bundle();
        bundle.putString("name", "Amplimesh");
        com.facebook.Request request = new com.facebook.Request(session, "me/albums", bundle, HttpMethod.POST, requestCallBack);

        RequestAsyncTask requestAsyncTask = new RequestAsyncTask(request);
        requestAsyncTask.execute();

        try {
            requestCallBack = new com.facebook.Request.Callback() {
                @Override
                public void onCompleted(Response response) {
                    JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
                    String postId = null;
                    try {
                        postId = graphResponse.getString("id");
                    } catch(Exception e) {
                        Log.v(GlobalVars.TAG, "JSON::" + postId);
                    }
                }
            };
        } catch(Exception e) {
            Log.v(GlobalVars.TAG, "Exception at::" + e.getMessage());
        }
    }
}
4

0 回答 0