我想在我的 android 应用程序中获取 Facebook 好友列表(不需要好友选择器)。我已按照 Facebook application development 上描述的程序进行操作
我也运行了示例,但对获取好友列表感到困惑。您的建议将不胜感激。
最佳答案
您可以使用此代码获取好友列表
String returnString = null;
JSONObject json_data = null;
try
{
JSONObject response = Util.parseJson(facebook.request("me/friends"));
JSONArray jArray = response.getJSONArray("data");
json_data = jArray.getJSONObject(0);
for(int i=0;i<jArray.length();i++){
Log.i("log_tag","User Name: "+json_data.getString("name")+
", user_id: "+json_data.getString("id"));
returnString += "\n\t" + jArray.getJSONObject(i);
};
flist.setText(returnString);
progressDialog.dismiss();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (JSONException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (FacebookError e)
{
e.printStackTrace();
}
我只得到 name 和 id ,如果你想得到不同的东西,
关于android - 如何在 Android 应用程序中获取 Facebook 好友列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22525049/