感谢。
答案 0 :(得分:12)
Bundle params = new Bundle();
params.putString("fields","birthday");
JSONObject jObject1 = new JSONObject(authenticatedFacebook.request("me/friends",params));
现在,如果您打印jobject1,您将获得所有朋友的生日列表..
响应将采用JSON格式,您必须从中获取值..
authenticatedFacebook是Facebook的对象..
如需进一步说明,请查看此link .....
private static final String[] PERMISSIONS =
new String[] {"friends_birthday","read_stream", "offline_access"};
确保您允许访问朋友的生日日期..
答案 1 :(得分:2)
获得朋友生日的最简单方法是什么?还是关系状态?
使用FQL我们可以在一个查询中获得用户朋友的生日和关系状态,如下所示:
SELECT uid, name, birthday_date, relationship_status
FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())
可以使用Facebook Android SDK在Android上实现,如下所示:
String query = "SELECT uid, name, birthday_date, relationship_status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())"
Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", query);
mAsyncFacebookRunner.request(null, params, new FQLRequestListener())
其中FQLRequestListener扩展了RequestListener。
JSON响应将如下所示:
{
"data": [
{
"uid": 1234567890,
"name": "John Smith",
"birthday_date": "06/16",
"relationship_status": "Married"
},
{
"uid": etc...
你需要
friends_birthday
许可
答案 2 :(得分:0)
try {
parameters.putString("format", "json");
parameters.putString(TOKEN, mAccessToken);
String url = "https://graph.facebook.com/me/friends?fields=id,name,birthday,location";
String response = Util.openUrl(url, "GET", parameters);
JSONObject obj = Util.parseJson(response);
Log.i("json Response", obj.toString());
JSONArray array = obj.optJSONArray("data");
if (array != null) {
for (int i = 0; i < array.length(); i++) {
String name = array.getJSONObject(i).getString("name");
String id = array.getJSONObject(i).getString("id");
Log.i(name,id);
}
}
}
您需要添加权限
friends_birthday
friends_location