$url = 'https://api.facebook.com/method/links.getStats?urls=http://google.com&format=json';
$get = json_decode($url, true);
echo 'Shares:' . $get['share_count'];
Why does this not return anything?
$url = 'https://api.facebook.com/method/links.getStats?urls=http://google.com&format=json';
$get = json_decode($url, true);
echo 'Shares:' . $get['share_count'];
Why does this not return anything?
json_decode
doesn't work with URLs, it expects string
as parameter. You have to fetch response of this request and pass it to json_decode
. Something like this:
$url = 'https://api.facebook.com/method/links.getStats?urls=http://google.com&format=json';
$get = json_decode(file_get_contents($url), true);
echo 'Shares:' . $get['share_count'];