Get Facebook “Like” count for every page on my domain

前端 未结 8 925
孤独总比滥情好
孤独总比滥情好 2020-12-07 13:35

I have integrated the Facebook \"Like\" button into a lot of pages in my site. I want to display the most \"Liked\" pages on my site in a list, but I can\'t figure out how

8条回答
  •  难免孤独
    2020-12-07 14:17

    Actually I would do it this way:

    $arrayOfPages = array('url1', 'url2', 'url3');
    
    $listOfPages = implode(',', $arrayOfPages);
    
    SELECT share_count, like_count, comment_count, total_count, url
    FROM link_stat
    WHERE url IN ($listOfPages)
    

    That would give you all the data with the URL as a unique identifier without having to break Facebook's policy against fake users. You can dynamically create the $arrayOfPages variable from a query on your site's database.

提交回复
热议问题