dounuogong0358 2013-10-24 05: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 05: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).

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部