获取最新API的Facebook好友列表 [英] Getting list of Facebook friends with latest API

查看:226
本文介绍了获取最新API的Facebook好友列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Facebook SDK的最新版本(可以连接到一个叫做'图形API'的东西,虽然我不确定)。我已经调整了Facebook的示例代码,让我连接到Facebook,并且它的工作...但我无法得到我的朋友列表。

I'm using the most recent version of the Facebook SDK (which lets to connect to something called the 'graph API' though I'm not sure). I've adapted Facebook's example code to let me connect to Facebook and that works... but I can't get a list of my friends.

$friends = $facebook->api('friends.get');

这会产生错误消息:致命错误:未捕获OAuthException:(#803)某些别名你要求不存在:friends.get抛出在/mycode/facebook.php第543行

This produces the error message: "Fatal error: Uncaught OAuthException: (#803) Some of the aliases you requested do not exist: friends.get thrown in /mycode/facebook.php on line 543"

不知道为什么这是或什么意思。有人可以告诉我正确的语法(最新的Facebook API)来获取一个朋友列表吗? (我试过$ friends = $ facebook-> api-> friends_get();并得到一个不同的错误,致命错误:调用一个成员函数friends_get()在一个非对象在/mycode/example.php第129行。)

No clue why that is or what that means. Can someone tell me the right syntax (for the latest Facebook API) to get a list of friends? (I tried "$friends = $facebook->api->friends_get();" and get a different error, "Fatal error: Call to a member function friends_get() on a non-object in /mycode/example.php on line 129".)

我可以在我的代码中确认这一点,事情是正常的:我有一个有效的会话连接到Facebook,我可以得到我的信息并将其转储到屏幕上,即...这个代码在失败的friend.get调用之前执行得很好:

I can confirm that BEFORE this point in my code, things are fine: I'm connected to Facebook with a valid session and I can get my info and dump it to the screen just... i.e. this code executes perfectly before the failed friends.get call:

$session = $facebook->getSession();
if ($session) {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
}
print_r($me);


推荐答案

我认为这是你想要的:

$friends = $facebook->api('/me/friends');

这篇关于获取最新API的Facebook好友列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆