Skip to content

Instantly share code, notes, and snippets.

@piotrkunicki
Created December 8, 2015 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrkunicki/7011b323d0b76d192891 to your computer and use it in GitHub Desktop.
Save piotrkunicki/7011b323d0b76d192891 to your computer and use it in GitHub Desktop.
Get facebook counters from url.
<?php
$source_url = "http://facebook.com/".$facebook_username;
$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url);
$xml = file_get_contents($url);
$xml = simplexml_load_string($xml);
$shares = $xml->link_stat->share_count;
$likes = $xml->link_stat->like_count;
$comments = $xml->link_stat->comment_count;
$total = $xml->link_stat->total_count;
$max = max($shares,$likes,$comments);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment