向用户显示他们的 FQL 选择结果

发布于 2025-01-04 11:01:49 字数 294 浏览 2 评论 0原文

我将提示用户通过三种方式过滤他们的朋友列表:

  1. 仅选择男性朋友
  2. 选择仅女性朋友
  3. 选择所有朋友

例如,过滤器1将是:

SELECT name, sex, pic_big, uid FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex = "male"

现在我需要向用户显示此信息!如何显示结果(过滤后)好友的网格或列表?

I will prompt users to filter their friend list in 3 ways:

  1. select only male friends
  2. select only female friends
  3. select all friends

for example, filter 1 will be:

SELECT name, sex, pic_big, uid FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex = "male"

now I need to display this information to the user! How can I show a grid or list of the resulting (filtered) friends?

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

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

发布评论

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

评论(1

权谋诡计 2025-01-11 11:01:49

好的...首先,您需要:

  • 一把舒适的椅子
  • 一台计算机(配有所有外围设备:键盘、鼠标、屏幕等)
  • 互联网连接
  • 确定
  • 本网站的书签;)

现在,回答您的问题。
Graph API Explorer 是一个很好的入门方式,可以浏览 API 以了解您的情况可以获得结果。您甚至可以使用 Graph API 运行 FQL 查询。

这里需要注意的一件事是,因为您正在处理用户的性别并且未在 API 中建立索引(这意味着它不能成为搜索条件),所以您必须首先检索用户的朋友,然后才能检索拨打电话检索每个用户的性别。


With regard to displaying the information. One could use a simple method of iterating through an array of data (possibly populated by a previous call to the API) and printing out the data wrapped in html tags.

这是一个简单的例子,迭代一个数组并在 html 中打印该数组的内容。

// $facebook_friends is populated with user information

foreach ($facebook_friends as $friend) {
    echo '<table border="0">';
    echo   '<tr><td>'.$friend['id'].'</td></tr>';
    echo   '<tr><td>'.$friend['name'].'</td></tr>';
    echo   '<tr><td>'.$friend['picture'].'</td></tr>';
    echo '</table>';
}

Ok... First of all you'll need :

  • A comfy chair
  • A Computer (complete with all peripherals : keyboard, mouse, screen, etc)
  • An Internet connection
  • Determination
  • A Bookmark to this site ;)

Now, to your question.
The Graph API Explorer is a great way to get started and poke around at the API to see how you can get results. You can even run FQL queries with the Graph API.

One thing to note here is that because you are dealing with the users gender and that is not indexed in the API (that means that it can not be a search criteria), you'll have to first retrieve the users friends and only after that make calls to retrieve each of the users gender.


With regard to displaying the information. One could use a simple method of iterating through an array of data (possibly populated by a previous call to the API) and printing out the data wrapped in html tags.

Here is a simple example or iterating through an array and printing the contents of that array in html.

// $facebook_friends is populated with user information

foreach ($facebook_friends as $friend) {
    echo '<table border="0">';
    echo   '<tr><td>'.$friend['id'].'</td></tr>';
    echo   '<tr><td>'.$friend['name'].'</td></tr>';
    echo   '<tr><td>'.$friend['picture'].'</td></tr>';
    echo '</table>';
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文