I’ve looked at a ton of related posts here and can’t seem to find an answer. I’ve been using the same code for months to get the Facebook share count of pages on my website. It’s worked [relatively] flawlessly, but suddenly it started returning nothing. After trying the source URL in the browser, I realized it’s throwing an API Limit error. Please help…
CODE:
[[[FUNCTION]]]
return jQuery.ajax({
url: 'https://graph.facebook.com/?fields=engagement&callback=FB.Share&id=' + permalinkWPSC + '&access_token=[[[ACCESS TOKEN]]]',
type: 'GET',
dataType: 'JSONP',
success: function(data) {
count = 0;
if (data.engagement) {
var count = Number(data.engagement.reaction_count + data.engagement.share_count + data.engagement.comment_count);
var share_count_http = 0;
if ($('[data-share-count]').length > 0) {
share_count_http = parseInt($('[data-share-count]').data('share-count'));
}
count = count + share_count_http;
}
$( ".share-num" ).html( count );
$( "span.fbCount" ).html( count );
}
});
[[[END FUNCTION]]]
So this is essentially using this URL string (with "URL" being actual URL and "ACCESSTOKEN" being the access token granted by the Facebook API: https://graph.facebook.com/?fields=engagement&callback=FB.Share&id=URL&access_token=ACCESSTOKEN
ERROR:
/**/ FB.Share({
"error": {
"message": "(#613) Calls to graph_url_engagement_count have exceeded the rate of 10 calls per 3600 seconds.",
"type": "OAuthException",
"code": 613,
"fbtrace_id": "Ad9vIHStlvzuGptF9LZmT-L"
}
});
Note that nothing else changed on the website or with traffic. Very strange…
3
Answers
The answer is in the error message:
They recently changed this.
The api documentation (https://developers.facebook.com/docs/graph-api/reference/v10.0/url) says:
It also says:
In practice this seems to mean if the likes, shares or comments are below a certain number it shows up as zero.
You’re summing up all engagement counts, so you might want to try accessing ‘og_object{engagement}’ field instead of ‘engagement’, it doesn’t seem to be affected by rate limits.
EDIT: Here’s your code edited to work with that.
Along with the rate limit issue, the bigger problem is with the Graph API change that they pushed out on May 25th, 2021. Version 10 and above now have this new stipulation (source):
However, it doesn’t end there. The Facebook team has responded in a few bug reports that posts with fewer than 100 engagements will no longer show any data. While that is fine, it isn’t accurate, as I have some posts with more than 100 engagements that are still returning nothing.
Some posts with 100+ engagements still do return data. The bigger problem is, the inaccuracy I’m seeing. It doesn’t seem like Facebook is even taking the time to test this properly on their end.
I’ve commented on some of the Facebook bug reports, along with others, as we are hoping to get some better answers from Facebook.
I also wrote up a longer summary here: https://novashare.io/docs/facebook-share-counts-graph-api-v10/