How to get Page Photo with the most likes & comments?

徘徊边缘 提交于 2019-12-24 09:49:23

问题


I'm using the Facebook PHP SDK to try and get the photo with the most number of likes for a Page, to be able to use as a "hero photo". The logic being that the photo with the most likes & comments is the most interesting to look at.

However, the only method I can think of is slow and cumbersome.

Is there a better method than using the below?

1. Query the Graph API for the albums belonging to a Page
2. Query the Graph API for Photos in each Album
3. Add the likes & comments for each photo
4. Re-order the list of photos and return the best few

As you can see it's a lot of work for a relatively low payoff, but I can't think of a better way to return the most popular photo of a given Page.

Any suggestions?


回答1:


It seems this is the only way to retrieve this information. I would recommend placing this series of queries in a cron job that runs periodically and updates a static file containing the results. Then you can just source that file and not have to run the queries for each user. If each user were to execute this batch of queries your application would be extremely slow or have a large load time...



来源:https://stackoverflow.com/questions/7271029/how-to-get-page-photo-with-the-most-likes-comments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!