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 nslt的可用模型,或者其他可以进行推理的现有模型
  • ¥15 arduino上连sim900a实现连接mqtt服务器
  • ¥15 vncviewer7.0安装后如何正确注册License许可证,激活使用
  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并2
  • ¥66 关于人体营养与饮食规划的线性规划模型
  • ¥15 基于深度学习的快递面单识别系统
  • ¥15 Multisim仿真设计地铁到站提醒电路
  • ¥15 怎么用一个500W电源给5台60W的电脑供电
  • ¥15 请推荐一个轻量级规则引擎,配合流程引擎使用,规则引擎负责判断出符合规则的流程引擎模板id
  • ¥15 Excel表只有年月怎么计算年龄