facebook 好友列表分页与 foreach 吗?
我正在检索 Facebook 好友列表,但它检索了大约十亿张照片(夸张)。我想知道如何在 foreach 循环中添加分页?另外,我的 PHP 编码是检索好友列表的最佳方法吗?
$user_friends = $facebook->api("/me/friends");
foreach ($user_friends as $friends) {
foreach ($friends as $friend) {
// do something with the friend, but you only have id and name
$id = $friend['id'];
$name = $friend['name'];
echo "<img src='https://graph.facebook.com/".$id."/picture' title='".$name."'>";
echo $name;
}
我需要某种 jquery 来进行分页吗?谢谢!
I'm retrieving facebook friendlist, but it retrieves like a billion photos (exaggerated). I was wondering how can I add pagination within a foreach loop? Also, would my PHP coding be the best way to retrieve the friendslist?
$user_friends = $facebook->api("/me/friends");
foreach ($user_friends as $friends) {
foreach ($friends as $friend) {
// do something with the friend, but you only have id and name
$id = $friend['id'];
$name = $friend['name'];
echo "<img src='https://graph.facebook.com/".$id."/picture' title='".$name."'>";
echo $name;
}
Would I need some kind of jquery to do the pagination? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 FQL 查询中使用 ORDER BY 和 LIMIT 关键字来实现,这样您只能获取照片的子集。
类似于(伪代码)
基本上,您将查询限制为 100 个照片块,并通过排序 ID 来跟踪您所在的位置。
You can use the ORDER BY and the LIMIT keywords in an FQL query to make it so you only get a subset of the photos.
Something like (pseudocode)
Basically you are limiting your query to 100 photo chunks and keeping track of where you are by ordering the IDs.