Arihant
Arihant

Reputation: 4047

PHP code for getting Facebook likes not working any more

I have been using the below code since a very long time to get the number of likes on various links. But now suddenly it stopped working. I did no changes to the code. I now have no idea where to look for answers or what has actually gone wrong.

Here's the code:

    mysql_real_escape_string($web[$i]);
    $site="http://graph.facebook.com/?ids=".$web[$i]."";
    $graph= file_get_contents($site);
    $json_string=$graph; 
    $array  = json_decode($json_string, true);
    $var[$i] =($array[$web[$i]]['shares']);

the $web array stores all the URLs. What can I try next?

Upvotes: 2

Views: 116

Answers (1)

Sashi Kant
Sashi Kant

Reputation: 13465

They have removed the open Rest API, to get this you need to implement the Oauth2.0 in your application.

The steps involved are :

1) Register your app
You will receive a CustomerKey and a Secret Code

2) Use both the Key and Code to receive an accessToken

3) Uses the same url which you are using, along with a new parameter which is accessToken=/*the one you received*/

Upvotes: 2

Related Questions