How to post COUNT to a Facebook wall on a Facebook (Public Profile) page that is not mine in PHP?

I need to save some statistics about the pages of a fan site (for example, account, promotions, etc.), but can’t understand how to count general messages on the wall? It is advisable to use FQL, but any ideas are appreciated

+4
source share
3 answers

here is the code (e.g. account, stocks, 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/>"; 
+1
source

Run the FQL query in 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"');

An access token may now be required in this FQL query - so try adding this if the above does not work.

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

+1
source

FQL does not have a COUNT function in its API, so you will have to receive all messages and read them yourself.

You can use something like PHP to do it like this:

  $fqlAPIParams = array( 'method' => 'fql.query', 'query' => ' SELECT post_id FROM stream WHERE actor_id = '.$pageId.' AND source_id = '.$pageId.' LIMIT 999999' ); $result = $facebook->api($fqlAPIParams); $postCount = 0; foreach( $result as $post ) { $postCount++; } 

Hope this can help someone, as the question is pretty old.

0
source

All Articles