如何获取所有的朋友的名字,身份证,生日,位置等。 [英] How to get all friends name, id, birthday, location, etc.. from facebook API in android?
问题描述
可能重复:
如何使用facebook api获取朋友的生日列表
我想在Android应用程序中显示包含名称,ID,生日,位置等信息的列表。
我成功击败在工作中,虽然以下代码我已经得到了朋友的名字和ID
Bundle parameters = new Bundle();
mAccessToken = facebook.getAccessToken();
try {
parameters.putString(format,json);
parameters.putString(TOKEN,mAccessToken);
String url =https://graph.facebook.com/me/friends;
String response = Util.openUrl(url,GET,参数);
JSONObject obj = Util.parseJson(response);
Log.i(json Response,obj.toString());
JSONArray array = obj.optJSONArray(data);
if(array!= null){
for(int i = 0; i String name = array.getJSONObject ⅰ).getString( 名称);
String id = array.getJSONObject(i).getString(id);
Log.i(name,id);
}
}
............
............
但是在json响应中没有生成,位置等字段。
什么是错误?解决方案使用FQL语言快速获取所需的所有信息:
$ this-> api&api(array('method'=>'fql.query','query'= >SELECT uid,name,first_name,middle_name,last_name,pic_square,hometown_location,current_location,profile_url,email,website FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())));
有关所有列及其相应列名的列表,请参阅: Facebook FQL参考
Possible Duplicate:
How to get friend's birthday list using facebook api?
I want to display the list that contain information like name, id, birthday, location from facebook in android application.
I am beat successful in work though the following code I have get the friend's name and ID
Bundle parameters = new Bundle();
mAccessToken = facebook.getAccessToken();
try {
parameters.putString("format", "json");
parameters.putString(TOKEN, mAccessToken);
String url = "https://graph.facebook.com/me/friends";
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);
}
}
............
............
but not get birthday, location, etc fields in json response.
what is mistake?
解决方案 Use the FQL language to get very quickly all the information you want:
$this->api->api(array('method'=>'fql.query','query'=>"SELECT uid,name,first_name,middle_name,last_name,pic_square,hometown_location,current_location,profile_url,email,website FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"));
For a list of all the tables with their corresponding column names I refer to: Facebook FQL Reference
这篇关于如何获取所有的朋友的名字,身份证,生日,位置等。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!