使用 Facebook Graph API 获取用户好友列表
我需要掌握应用程序好友列表中的用户,以过滤好友选择器中显示的用户。我知道我可以调用以下命令并获取列表:
https://graph.facebook.com/me/friends?access_token=<access_token>
我用自己的帐户在地址栏中尝试了它,它似乎完全按照我需要的方式工作。问题是,我不知道如何在 js 文件本身中使用它。我尝试调用它并通过 jquery 调用获取数据,但它似乎没有返回任何有用的信息。
$.get("https://graph.facebook.com/me/friends",
{access_token: <access_token>},
function(data){ document.write("Data Loaded: " + data);});
我应该如何在我的 js 文件中调用它,然后实际利用这些信息?谢谢。
I need to get a hold of a user of my app's list of friends to filter the users that show up in a friend picker. I know I can call the following and get the list:
https://graph.facebook.com/me/friends?access_token=<access_token>
I tried it out in the address bar with my own account and it seems to work exactly as I need it to. Problem is, I don't know how to make use of it in a js file itself. I tried calling it and getting the data out with a jquery call but it doesn't seem to return anything helpful.
$.get("https://graph.facebook.com/me/friends",
{access_token: <access_token>},
function(data){ document.write("Data Loaded: " + data);});
How should I be calling this in my js files and then actually make use of the information? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更新:根据V2.0中引入的更改、
/me/friends
将仅返回应用好友。正确的方法是使用 Facebook Javascript-SDK,类似这样:
请注意:
UPDATE: As per the changes introduced in V2.0,
/me/friends
will return app friends only.The right way to do that is by using the Facebook Javascript-SDK, something like this:
Please note that:
如果您想使用 JavaScript 从图表中提取信息,则必须使用 JS SDK 和 FB.api 方法进行调用。
If you want to extract information from the Graph with JavaScript, you will have to use the JS SDK and FB.api method to make the calls.
它对我有用:
结果:
It's working for me :
Result :