2

Is it just me or did the Facebook Share button that displays the count of shares and likes just stop working over the past few days? The sharing still works, the count of shares no longer displays.

The link that is generated look like this http://www.facebook.com/sharer.php?u= and the JavaScript file on my page is this http://static.ak.fbcdn.net/connect.php/js/FB.Share

I haven't changed anything and this has worked for years

1 Answer 1

3

The feed dialog, in conjunction with FB.ui, is the new way to accomplish this when using the Javascript SDK. You should considering updating to the new SDK. At which point, you'd be able to display the share count of each url on your site by using Facebook's Graph API. Example Below.

Here is an object the graph API returns for google.com. Notice the total share count.

{
    "id": "http://google.com",
    "shares": 12265103,
    "comments": 10121
}

If using something like jQuery, a simple GET request can retrieve the above JSON

var shareUrl = 'http://google.com';
var endpoint = 'http://graph.facebook.com/?id=';
var fbSharer = 'https://www.facebook.com/sharer/sharer.php?u=';

$.get(endpoint + shareUrl, function(data){

    $('a[href="'+ fbSharer + shareUrl +'"] .count').text(data.shares);

});    

Assuming some HTML like:

<a href="https://www.facebook.com/sharer/sharer.php?u=http://google.com">
    <span class="count">0</span>
    Share Me
</a>

jsfiddle Demo

6
  • Brian for the rest of us who have now clue how the results of count is integrated in to the new SDK process, can you point us to the right page that shows us how the ingratiation process looks like on a real FB.ui exmaple? When I go there - developers.facebook.com/docs/sharing/reference/feed-dialog/v2.2 there is no training in integrating count into FB.ui
    – klewis
    May 14, 2015 at 22:33
  • 1
    Im pretty sure seeing the current users personal share count, if thats what you're referring to, is a privacy no no and the share dialogue relates directly to a user sharing not the shared content. So if you want to see how many times the url you're sharing has been shared simply make a GET request to fb graph graph.facebook.com/?id=http://google.com May 15, 2015 at 4:03
  • Thank you so much Brian, can I use javascript to pull these values onto my personal page?
    – klewis
    May 15, 2015 at 11:39
  • @blackhawk no problem and yes an ajax request is perfectly suitable. May 15, 2015 at 13:32
  • @blackhawk updated my answer to include some example jQuery May 16, 2015 at 2:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.