Android Facebook好友生日

Android Facebook好友生日,android,facebook,facebook-graph-api,Android,Facebook,Facebook Graph Api,我正在我的应用程序中集成facebook sdk。我需要获取用户朋友的姓名和生日。我添加了“阅读好友列表”、“用户生日”、“用户好友”、“朋友生日” 当使用应用程序的管理员facebook ID登录时,我能够正确获取生日列表。但当我使用任何其他帐户登录时,JSON响应中没有生日字段 我已经禁用了沙盒模式。在应用程序仪表板中显示“此应用程序是实时的(对所有用户可见)”对于JSON对象,请输入一些代码让我们帮助您。 我个人用这个来获得facebook用户的生日 首先,您是否为用户设置了权限?如果您想

我正在我的应用程序中集成facebook sdk。我需要获取用户朋友的姓名和生日。我添加了“阅读好友列表”、“用户生日”、“用户好友”、“朋友生日”

当使用应用程序的管理员facebook ID登录时,我能够正确获取生日列表。但当我使用任何其他帐户登录时,JSON响应中没有生日字段


我已经禁用了沙盒模式。在应用程序仪表板中显示“此应用程序是实时的(对所有用户可见)”

对于JSON对象,请输入一些代码让我们帮助您。 我个人用这个来获得facebook用户的生日 首先,您是否为用户设置了权限?如果您想访问用户的生日信息,这一点非常重要

如果用户不为null,通常您可以通过user.getBirthday()获得生日,因为我看到您正在使用新的facebook SDK

您可以设置权限,例如在使用facebook authbutton时

 authButton.setReadPermissions(Arrays.asList("user_location", "user_birthday", "user_likes"));
或者您可以重新授权权限

Session.ReauthorizeRequest reauthRequest = new Session.ReauthorizeRequest(this, PERMISSIONS).
                setRequestCode(REAUTHORIZE_ACTIVITY).
                setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
session.reauthorizeForPublish(reauthRequest);
其中权限是一个包含您的权限的数组

确定尝试此操作

Session.ReauthorizeRequest reauthRequest = new Session.ReauthorizeRequest(this, PERMISSIONS).
                setRequestCode(REAUTHORIZE_ACTIVITY).
                setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
session.reauthorizeForPublish(reauthRequest);
  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";
String[]facebook\u权限={“用户照片”、“好友生日”、“好友照片”};
==========================================================================
公共类FriendListAdapter扩展BaseAdapter实现SectionIndexer{
私人停车场;
私有字符串[]节;
私有GetProfilePictures picturesGatherer=null;
友人名单友人名单;
哈希表listofshit=null;
公共FriendsListAdapter(FriendsList FriendsList){
d(Log_标记,“FriendListAdapter()”);
this.friendsList=friendsList;
sections=新字符串[getCount()];
listofshit=新哈希表();
对于(int i=0;i
感谢您的回复…请注意,我想获取用户朋友的生日,而不是用户的生日…您也可以在此处看到此帖子,您也可以在[此处][1][1]看到此帖子: