How to COUNT total wall posts of Facebook Fan Page (Public Profile) which is not mine in PHP?

10,020

Solution 1

here is code to (like count, shares, etc)

$source_url = "http://www.flightpodcast.com/episode-6-john-bartels-qantas-qf30";
$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url);
$xml = file_get_contents($url);//echo "<pre/>";print_r($xml);exit;
$xml = simplexml_load_string($xml);
echo "<b>Shares:</b> ".$shares = $xml->link_stat->share_count;echo "<br/>";
echo "<b>Likes:</b> ".$likes = $xml->link_stat->like_count;echo "<br/>";
echo "<b>Comments:</b> ".$comments = $xml->link_stat->comment_count;echo "<br/>";
echo "<b>Total:</b> ".$total = $xml->link_stat->total_count;echo "<br/>";

Solution 2

Run a FQL query against the link_stat table:

FQL: SELECT share_count, like_count, comment_count, total_count FROM link_stat WHERE url="http://example.com"

PHP: $facebook->api_client->fql_query('SELECT share_count, like_count, comment_count, total_count FROM link_stat WHERE url="http://example.com"');

This FQL query might require now an access token - so try adding that if the above fail.

You can also access the graph api: http://graph.facebook.com/?id=http://example.com.

Share:
10,020
rkcell
Author by

rkcell

Updated on June 04, 2022

Comments

  • rkcell
    rkcell almost 2 years

    I need to store some stats about fan pages (like count, shares, etc) but cant understand how to count Page's total wall posts? Preferably want to use FQL but any ideas appreciated

  • rkcell
    rkcell almost 13 years
    thank you for support, but I need to count Wall Posts, likes and shares already implemented via FQL
  • rkcell
    rkcell almost 13 years
    Thanks for the post, but I need Wallposts count and nothibg else ))