0

I am integrating facebook sdk in my app. I need to get the user's friends names and their birthdays . I have added the"read_friendlists", "user_birthday", "user_friends", "friends_birthday" .

When logged in with app's Admin facebook ID , I am able to get the birthday list properly. But when I log in with any another account , there is no birthday field in the JSON response.

PS: I have already disable the sandbox mode. In the app dashboard it's showing "This app is live(Visible to all users)"

lingareddyk
  • 175
  • 4
  • 12
  • and you can see this post too [here][1] [1]: http://stackoverflow.com/questions/14000802/android-getting-friends-birthday-using-graph-api-facebook-sdk-3-0?rq=1 – bourax webmaster Nov 15 '13 at 13:17

2 Answers2

0

for the JSON object, please put some code to let us help you. I personnaly use this to get facebook user birthday First of all have you set permission for user_birthday? it's very important if you want to access user_birthday information

if the user is not null usually you can get the birthday by user.getBirthday() because from what I see you're using the new facebook SDK

you can set permission for example when you using the facebook authbutton

 authButton.setReadPermissions(Arrays.asList("user_location", "user_birthday", "user_likes"));

or you can reauthorize permission

Session.ReauthorizeRequest reauthRequest = new Session.ReauthorizeRequest(this, PERMISSIONS).
                setRequestCode(REAUTHORIZE_ACTIVITY).
                setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
session.reauthorizeForPublish(reauthRequest);

Where The PERMISSION is an array containing your permission

bourax webmaster
  • 748
  • 7
  • 18
0

ok try this

  String[] facebook_permissions = { "user_photos", "friends_birthday", "friends_photos" };

==========================================================================

public class FriendListAdapter extends BaseAdapter implements SectionIndexer {
private LayoutInflater mInflater;
private String[] sections;
private GetProfilePictures picturesGatherer = null;
FriendsList friendsList;
Hashtable<Integer, FriendItem> listofshit = null;

public FriendListAdapter(FriendsList friendsList) {
    Log.d(LOG_TAG, "FriendListAdapter()");
    this.friendsList = friendsList;
    sections = new String[getCount()];
    listofshit = new Hashtable<Integer, FriendItem>();
    for (int i = 0; i < getCount(); i++) {
        try {
    sections[i] = jsonArray.getJSONObject(i).getString("name").substring(0);
sections[i] = jsonArray.getJSONObject(i).getString("birthday").substring(1);
        } catch (JSONException e) {
            sections[i] = "";
            Log.e(LOG_TAG, "getJSONObject: " + e.getMessage());
        }
    }
    if (picturesGatherer == null) {
        picturesGatherer = new GetProfilePictures();
    }
    picturesGatherer.setAdapterForListener(this);
    mInflater = LayoutInflater.from(friendsList.getBaseContext());
}

public int getCount() {
    Log.d(LOG_TAG, "getCount()");
    if (jsonArray == null)
        return 0;
    return jsonArray.length();
}

public Object getItem(int position) {
    Log.d(LOG_TAG, "getItem()");
    return listofshit.get(position);
}

public long getItemId(int position) {
    Log.d(LOG_TAG, "getItemId()");
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    Log.d(LOG_TAG, "getView(" + position + ")");

    JSONObject jsonObject = null;
    try {
        jsonObject = jsonArray.getJSONObject(position);
    } catch (JSONException e) {
        Log.e(LOG_TAG, "getJSONObject: " + e.getMessage());
    }

    FriendItem friendItem;

    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.single_friend, null);
        friendItem = new FriendItem();

        convertView.setTag(friendItem);
    }
    else {
        friendItem = (FriendItem) convertView.getTag();
    }

    friendItem.friendPicture = (ImageView) convertView.findViewById(R.id.picture_square);
    friendItem.friendName = (TextView) convertView.findViewById(R.id.name);
    friendItem.friendDob = (TextView) convertView.findViewById(R.id.dob);
    friendItem.friendLayout = (RelativeLayout) convertView.findViewById(R.id.friend_item);

    try {
        String uid = jsonObject.getString("uid");
        String url = jsonObject.getString("pic_square");
        friendItem.friendPicture.setImageBitmap(picturesGatherer.getPicture(uid, url));
    } catch (JSONException e) {
        Log.e(LOG_TAG, "getJSONObject: " + e.getMessage());
        friendItem.friendName.setText("");
        friendItem.friendDob.setText("");
    }

    try {
        friendItem.friendName.setText(jsonObject.getString("name"));
        friendItem.friendDob.setText(jsonObject.getString("birthday"));
    } catch (JSONException e) {
        Log.e(LOG_TAG, "getJSONObject: " + e.getMessage());
        friendItem.friendName.setText("");
        friendItem.friendDob.setText("");
    }

    listofshit.put(position, friendItem);

    return convertView;
}

public int getPositionForSection(int position) {
    return position;
}

public int getSectionForPosition(int position) {
    return position;
}

public Object[] getSections() {
    return sections;
}
}

class FriendItem {
TextView friendDob;
int id;
ImageView friendPicture;
TextView friendName;
RelativeLayout friendLayout;

}

==============================================================================

String query = "select name, uid, pic_square, birthday from user where uid in 
(select uid2 from friend where uid1=me()) order by name";
bourax webmaster
  • 748
  • 7
  • 18
  • and you can see this post too here[link](http://stackoverflow.com/questions/14000802/android-getting-friends-birthday-using-graph-api-facebook-sdk-3-0?rq=1) – bourax webmaster Nov 15 '13 at 13:15