如何获取好友的姓名、头像

发布于 2024-10-30 21:41:08 字数 112 浏览 4 评论 0原文

有人可以帮助编写一个示例 Facebook 应用程序的代码,该应用程序仅获取所有朋友的姓名和图像并将其打印到状态吗?我尝试了 Facebook 网站上提供的一些代码,但由于某种原因失败了,而且我无法理解该错误。

Can someone help with code for a sample Facebook application which just gets all the friends name, and images and prints them to the status? I tried some code provided in Facebook's site, but for some reason it failed and I was not able to understand the error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

拥醉 2024-11-06 21:41:09

基本 FQL 方法(使用新的 PHP SDK):

<?php
// assuming we're using the newest version of the Facebook PHP SDK
$fb = new Facebook(array(
     'appId' => '<YOUR_APP_ID>',
     'secret' => '<YOUR_APP_SECRET>'
));

if (!$fb->getSession())
{
    // prompt for install if necessary
    header("Location: ".$fb->getLoginUrl());
}

// Contains basic user information
$user = $fb->api('/me');

// use FQL to get the results
$friends = $fb->api(array(
    'method' => 'fql.query',
    'query' => 'SELECT name, pic_big, pic_small, pic_square 
         FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())'
));

FQL 用户表文档

Basic FQL approach (using the new PHP SDK):

<?php
// assuming we're using the newest version of the Facebook PHP SDK
$fb = new Facebook(array(
     'appId' => '<YOUR_APP_ID>',
     'secret' => '<YOUR_APP_SECRET>'
));

if (!$fb->getSession())
{
    // prompt for install if necessary
    header("Location: ".$fb->getLoginUrl());
}

// Contains basic user information
$user = $fb->api('/me');

// use FQL to get the results
$friends = $fb->api(array(
    'method' => 'fql.query',
    'query' => 'SELECT name, pic_big, pic_small, pic_square 
         FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())'
));

FQL User Table documentation

檐上三寸雪 2024-11-06 21:41:09

如果您发布错误&,那就太好了 Facebook

顺便说一句:

  • 应用程序必须托管在启用了 CURL 的托管上。
  • 您是否有正确的开发人员密钥(或者在那里如何调用它)?
  • 应用程序代码是否只是从示例中复制的?如果是,您必须更改一些内容,例如开发密钥。
  • 您需要 OAuth,您有吗?

我能猜到的就是这些。

If would be nice if you post error & code.

By the way:

  • Facebook application must be hosted on hosting with CURL enabled
  • Do you have your correct Developer Key (or how it is called there)?
  • Does application code have been just copied from examples? If yes you have to change some things like dev key.
  • You will need OAuth, do you have it?

That all i can guess.

九歌凝 2024-11-06 21:41:09

需要在域 www.xyz.com/fb/app 中添加 facebook php sdk
然后将应用程序存储在其中!
跑吧!

没有人告诉我:( :x

need to add the facebook php sdk in the domain www.xyz.com/fb/app
then store the app in it !
and run !

nobody told me that :( :x

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文