Skip to content

Instantly share code, notes, and snippets.

@kythin
Created January 10, 2014 05:27
Show Gist options
  • Save kythin/8347409 to your computer and use it in GitHub Desktop.
Save kythin/8347409 to your computer and use it in GitHub Desktop.
Get the number of facebook liked for a URL (which would include links to images, etc)
function getLikesCountForURL($url) {
$fullurl = 'https://api.facebook.com/method/fql.query?query=SELECT%20like_count%20FROM%20link_stat%20WHERE%20url=%22'.$url.'%22&format=json';
$response = json_decode(file_get_contents($fullurl),true);
return $response[0]['like_count'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment