AyumuKasuga / SocialShare

jQuery plugin for creating custom like buttons and like counters
MIT License
143 stars 44 forks source link

Facebook Share count not working #24

Open rrfranco92 opened 8 years ago

rrfranco92 commented 8 years ago

Hey,

I noticed that my facebook wasn't working and I went to see what was happening. I've found out that the facebook API you are using was deprecated today, 18th August.

Can you take a look at this? Will it possible using the new API or not?

Regards!

AyumuKasuga commented 8 years ago

Hello, @rrfranco92 ! Thank you for the report. Looks like facebook completely disabled their rest api. Now we can't get share counter from browser without access token. Currently i can't find the way how to get around this.

Also you can use graph api https://developers.facebook.com/docs/graph-api

ldo-tamedia commented 8 years ago

Try this:

    function facebook(url, callback){

        $.ajax({
            type: 'GET',
            dataType: 'jsonp',
            url: 'http://graph.facebook.com?id='+url,
        })
        .done(function (data){callback(data.share.share_count)})
        .fail(function(){callback(0);})
    }

but apparently they removed a part of the results

AyumuKasuga commented 8 years ago

Hello @ldo-tamedia ! Thanks for your comment. Yes your solution works, but it should not work :). Regarding documentation we should provide access_token, but we can see it works well without token. And everything fine, we again found unofficial method to fetch share counters bypassing official graph API, but if you try to multiple refresh this url you can get error like this:

/**/ callback({
   "error": {
      "message": "(#4) Application request limit reached",
      "type": "OAuthException",
      "is_transient": true,
      "code": 4,
      "fbtrace_id": "DfFpebWbEsl"
   }
});

Because they have limits requests per user IP. But anyway I decided to add this method, be careful with it and be ready that not every user can see this counter... Also facebook can disable this hack at any time.