简体   繁体   中英

How to add permission for getting birthday from Facebook

I'm unable to add permission for birthday, please help me out... thanks in advance.

sample source code is :

Session.openActiveSession(this, true, new Session.StatusCallback() {

        // callback when session changes state
        @SuppressWarnings("deprecation")
        @Override
        public void call(Session session, SessionState state,
                Exception exception) {
            if (session.isOpened()) {
                // make request to the /me API
                Request.executeMeRequestAsync(session,
                        new Request.GraphUserCallback() {

                            // callback after Graph API response with user
                            // object
                            @Override
                            public void onCompleted(GraphUser user,
                                    Response response) {
                                if (user != null) {


                                }
                            }
                        });
            } 
        }
    });

尝试这个,

.setPermissions(Arrays.asList("user_birthday","email"))

private static final List PERMISSIONS = Arrays.asList(""user_birthday""); //declaration

onClickPostStatusUpdate();// on button click call this function

private void onClickPostStatusUpdate() {

    performPublish(PendingAction.POST_STATUS_UPDATE);

}

private void performPublish(PendingAction action) {

    Session session = Session.getActiveSession();
    if (session != null) {
        pendingAction = action;
        if (hasPublishPermission()) {
            // We can do the action right away.
            handlePendingAction();
        } else {
            // We need to get new permissions, then complete the action when we get called back.
            session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, PERMISSIONS));
        }
    }

}
user.getBirthday();

我记住使用它并将其存储为字符串。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM