Skip to content

Instantly share code, notes, and snippets.

@lastguest
Created September 7, 2018 12:56
Show Gist options
  • Save lastguest/0e0d3647056e243c79b3ed3ea3ceb468 to your computer and use it in GitHub Desktop.
Save lastguest/0e0d3647056e243c79b3ed3ea3ceb468 to your computer and use it in GitHub Desktop.
[PHP] getFacebookSharesForURL
<?php
function getFacebookSharesForURL($url){
return (int)substr(
$data = file_get_contents("http://graph.facebook.com/?id=" . urlencode($url)),
$p = strpos($data, $t = '"share_count":') + strlen($k),
(strpos($data,'}',$p) ?: strpos($data,',',$p)) - $p
);
}
// Esempio :
// echo getFacebookSharesForURL("https://www.helloworld.it/viaggi/citta-brutte-mondo");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment