Facebook REST API is deprecated for versions v2.1 and higher

If you are trying to get the share count of your posts with the facebook REST API endpoint

https://api.facebook.com/method/links.getStats?format=json&urls=https://www.mashshare.net 

you get the error message

REST API is deprecated for versions v2.1 and higher.

The reason for this is that facebook switched the REST API endpoint into deprecated state on february 7th with an official announcement saying:

Version 2.0 will expire on August 7, 2016, two years after the release of v2.1.
The FQL and REST APIs are no longer available in v2.1: Previously announced with v2.0, apps must migrate to versioned Graph API calls starting with v2.1.

Source: https://developers.facebook.com/docs/apps/changelog

Today on August 19th 2016 facebook shut down the api completely and we do not get any results except the error message above.

So how to get shares of a url?

We can switch over to their graph api and their public available endpoint

http://graph.facebook.com/?id=https://www.mashshare.net

This endpoint is returning the shares of your posts and its still public available but it is possible that this endpoint will be closed to the public in the future and only available via oAuth authentication.

Do you have more insights?
So please let us know in the comments
or send us a mail about this serious issue.

 

9 thoughts on “Facebook REST API is deprecated for versions v2.1 and higher”

  1. Iam using rest api to get the  like count of a facebook page and now iam facing deprecated issue.How to solve?

    • You get likes via the graph api:

      $access_token = 'YOUR ACCESS TOKEN'; //Replace it with your Access Token
      $json = json_decode(file_get_contents("https://graph.facebook.com/".$username."?access_token=".$access_token),true);
      return $json;
      • We have to create new app or some older apps will work.

        if possible then please give the complete code for likes count of url working with new system.

        Thanks in advance..

  2. How to get the SHARE variable, after having performed the query json?, Example:

    **********
    <?php
    $urlface1 = “http://www.mywebsite.com/post/url”;
    $variable = @json_decode(file_get_contents(“http://graph.facebook.com/?id=$urlface1“));
    echo $variable->share_count;
    ?>
    **********

    I can not get the variable!

    Help me?

    I also tried……
    $querypl = json_decode(file_get_contents(“http://graph.facebook.com/?id=$urlface1“),true);
    return $querypl;

     

  3. I already solved…. And without using the expression “access_token” or “$username”

    *********************
    <?php
    $urlface = “http://www.mywebsite.com/post/$urlface“;
    $queryfb = @json_decode(file_get_contents(“http://graph.facebook.com/?id=$urlface“));
    echo “<strong>”.$variable->share->share_count.”</strong>”;
    ?>
    *********************

    • Thanks for sharing your solution. Its working for a small website which does not do more than a few dozen quick calls to the Facebook server. If you have more hits you will run quickly into the facebook api rate limit which means that next requests will result only a error message and no share count. If you have a high traffic site its better to use an access token. So you get 200 calls per hour than.

Comments are closed.

x
Follow MashShare?