我正在尝试使用 Facebook id 检索 Facebook 好友的详细信息(名字、姓氏、性别等)
我的代码是:-
try
{
params.putString("fields", "first_name");
params.putString("fields", "last_name");
params.putString("fields", "link");
params.putString("fields", "gender");
params.putString("fields", "birthday");
JSONObject json = new JSONObject(facebook.request(Id, params));
JSONArray array = json.getJSONArray("data");
if(array != null)
{
for(int i=0;i<array.length();i++)
{
String name = array.getJSONObject(i).getString("name");
String birthday = array.getJSONObject(i).getString("friends_birthday");
String location = array.getJSONObject(i).getString("friends_location");
String web = array.getJSONObject(i).getString("friends_website");
System.out.println(name+"-"+birthday+"-"+location+"-"+web);
}
}
}
catch(Exception e)
{
}
我在哪里犯了错误。请帮我。提前致谢
My Code is:-
try
{
params.putString("fields", "first_name");
params.putString("fields", "last_name");
params.putString("fields", "link");
params.putString("fields", "gender");
params.putString("fields", "birthday");
JSONObject json = new JSONObject(facebook.request(Id, params));
JSONArray array = json.getJSONArray("data");
if(array != null)
{
for(int i=0;i<array.length();i++)
{
String name = array.getJSONObject(i).getString("name");
String birthday = array.getJSONObject(i).getString("friends_birthday");
String location = array.getJSONObject(i).getString("friends_location");
String web = array.getJSONObject(i).getString("friends_website");
System.out.println(name+"-"+birthday+"-"+location+"-"+web);
}
}
}
catch(Exception e)
{
}
where do I am commtting mistake. please help me. Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们可以获取用户好友的详细信息
捆绑包参数 = new Bundle();
字符串 accessToken = facebook.getAccessToken();
we can get the details of a user's friends
Bundle params = new Bundle();
String accessToken = facebook.getAccessToken();
如果你不告诉我们你想用你的代码做什么以及它出了什么问题,我们很难为你提供帮助。
但是,通过查看您的代码,我会告诉您确认您是否以正确的方式放置了所需的字段。如果 params 像哈希表一样工作,您将覆盖关键“字段”的值 - 因此,您将只询问生日,而不是询问名字、姓氏等。
it is very hard to help you without you telling us what you are trying to do with your code and what is going wrong with it.
However, by looking at your code, I would tell you to confirm that you are putting the fields you want in the correct way. If params works like an hashtable, you would be overritting the values for key "fields" - so instead of asking for first_name, last_name, etc you would be asking only for birthday.