Skip to content

Instantly share code, notes, and snippets.

@gimesi
Last active December 22, 2015 19:39
Show Gist options
  • Save gimesi/6521397 to your computer and use it in GitHub Desktop.
Save gimesi/6521397 to your computer and use it in GitHub Desktop.
Show the number of likes of a Facebook page with this php snippet using the cURL function.
// Show the number of likes of a Facebook page
<?php
$url = "http://graph.facebook.com/YOURPAGENAME"; // enter your fb-sitename here
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$results = curl_exec($ch);
curl_close($ch);
$json = json_decode($results, true);
?>
<?php echo $json['likes']; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment