Amir Mahmoodi
Amir Mahmoodi

Reputation: 100

Why I get null for user friend's birthday in android app that use facebook api?

I write this code in my android app i can get the user friends name but i cannot get their birthday what should I do?I think that I have problem with permissions but I don;t know where.

Session s = new Session(this);
    Session.setActiveSession(s);
    Session.OpenRequest request = new Session.OpenRequest(this);
    request.setPermissions(Arrays.asList("friends_birthday","user_friends","public_profile"));
    request.setCallback( new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            if (session.isOpened()) {
                Request myFriendsRequest = Request.newMyFriendsRequest(session, new Request.GraphUserListCallback() {
                    @Override
                    public void onCompleted(List<GraphUser> users, Response response) {
                        if (users != null) {
                            TextView welcome = (TextView) findViewById(R.id.welcome);

                            for (GraphUser user : users) {
                                // Here I can get the friend name
                                welcome.setText(welcome.getText() + "Hello " + user.getName() + "!");
                                // But here I cannot get birthday and it returns null
                                Toast.makeText(MyContext, user.getBirthday(), Toast.LENGTH_SHORT).show();

                            }
                        }
                    }
                });
    Bundle requestParams = myFriendsRequest.getParameters();
    requestParams.putString("fields", "name,birthday");
    myFriendsRequest.setParameters(requestParams);
    myFriendsRequest.executeAsync();
            } 
        }
    });
    s.openForRead(request);

Upvotes: 0

Views: 301

Answers (1)

Tobi
Tobi

Reputation: 31489

That's because all friends_* permissions have been removed with Graph AP v2.0. You can't access their data anymore, except name and profile picture.

See

Upvotes: 2

Related Questions