Facebook 查询语言仅提供用户 ID
我正在尝试打印使用我的应用程序的用户的朋友。使用 Facebook 查询语言(FLQ)来做到这一点。但查询只给出用户 ID。我如何获取带有个人资料图片的用户名
这是我的代码:
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxx',
'cookie' => true, // enable optional cookie support
));
$session = $facebook->getSession();
if ($session) {
try {
$some_friends = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT uid2 FROM friend WHERE uid1='.$facebook->getUser().' LIMIT 10'
));
} catch (FacebookApiException $e) {
error_log($e);
}
}
print_r($some_friends);
这是结果:
Array (
[0] => Array ( [uid2] => 521117187 )
[1] => Array ( [uid2] => 526583873 )
[2] => Array ( [uid2] => 527579769 )
[3] => Array ( [uid2] => 531219912 )
[4] => Array ( [uid2] => 533654770 )
[5] => Array ( [uid2] => 539141589 )
[6] => Array ( [uid2] => 539243220 )
[7] => Array ( [uid2] => 539342366 )
[8] => Array ( [uid2] => 549294033 )
[9] => Array ( [uid2] => 557508969 )
)
已解决...
I'm trying to print friends of user who uses my application.Using Facebook Query Language(FLQ) to do it. But query gives just user id's.How can i get usernames with profile pictures
Here is my code:
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxx',
'cookie' => true, // enable optional cookie support
));
$session = $facebook->getSession();
if ($session) {
try {
$some_friends = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT uid2 FROM friend WHERE uid1='.$facebook->getUser().' LIMIT 10'
));
} catch (FacebookApiException $e) {
error_log($e);
}
}
print_r($some_friends);
Here is the result:
Array (
[0] => Array ( [uid2] => 521117187 )
[1] => Array ( [uid2] => 526583873 )
[2] => Array ( [uid2] => 527579769 )
[3] => Array ( [uid2] => 531219912 )
[4] => Array ( [uid2] => 533654770 )
[5] => Array ( [uid2] => 539141589 )
[6] => Array ( [uid2] => 539243220 )
[7] => Array ( [uid2] => 539342366 )
[8] => Array ( [uid2] => 549294033 )
[9] => Array ( [uid2] => 557508969 )
)
solved...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过将 uid 发布到
http://graph.facebook.com/UID/picture
例子
http://graph.facebook.com/557508969/picture
也是他的名字
http://graph.facebook.com/557508969/(JSON 编码)
you can get their picture by posting uid to
http://graph.facebook.com/UID/picture
example
http://graph.facebook.com/557508969/picture
also his name by getting
http://graph.facebook.com/557508969/ (JSON encoded)
我认为如果我理解你的问题,你必须将你的选择查询更改为
。
i think you have to change your select query to
if i understood your question.
您需要使用 FQL 子查询,因为朋友表不包含有关用户的更多信息。试试这个:
FQL Subqueries are what you need to be using, as the friend table doesn't contain any more information on the users. Try this: