Reputation: 1781
i am trying to get the number of facebook shares for my website link, using facebook graph api call, for this i have written the below code:
$url = "http://graph.facebook.com/http://www.example.com/";
$content = file_get_contents($url);
$json = json_decode($content, true);
if (isset($json["shares"]) && $json["shares"] >= 1) {
echo "Thanks for sharing";
} else {
echo "sorry, you have not yet shared my link.";
}
the above code works perfect on my localhost, but when i tried the same code, it always print me sorry, you have not yet shared my link
, even when i shared it on facebook.
please help, what i need to do more.. so that it works on live server too.. thanks in advance
Upvotes: 0
Views: 347
Reputation: 1781
well after doing lots of search i got to know my server does not has allow_url_fopen = On
so i edited my php.ini
file.. now it is working perfect...
the file_get_contents
method requires allow_url_fopen = On
....
i have posted this answer so that anyone else looking for this.. may get help..
thanks every one.. who viewed my question..
Upvotes: 1