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?
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...
精彩评论