dounuogong0358 2013-10-24 13:21
浏览 31
已采纳

使用API​​和Laravel加载所有Facebook好友的最有效方式,以便进一步处理

I'm building an application which should display all of the users Facebook friends. The entire list should be searchable (name) and filterable based on gender and in the future other parameters such as location.

So Imagine you go the the web page, you get your first 30 friends loaded (or whatever fits on your screen) and as you scroll, more friends will load. As soon as you type, the system will begin to search for names.

Now i'm wondering what an efficient way of doing this would be. Obviously I can't load all the friends on the page because some people have over 1000 friends and the page also displays their profile picture.

Because I need to do the filtering I'm not quite sure if I should load the entire friends object in one go and do the processing with PHP afterwards, or if I should load it asynchronously from facebook as the user scrolls down.

My ideas is to load the entire friends list, flash it in the session and grab it again when processing is required such as filtering and searching.

Would that be the way to go?

  • 写回答

1条回答 默认 最新

  • douanrang4728 2013-10-24 13:31
    关注

    Friends don´t change very fast, so you can just grab all of them at once with limit set to 5000 (maximum of friends) and use them in the whole session. I just hope the API allows the limit to be set that high.

    me/friends?fields=id,name&limit=5000
    

    It is the only way you can use the search, and only one API call is needed. After all you only get the Names, and add Avatars as soon as they are visible in your app (Right after searching, for example).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 这个复选框什么作用?
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合