Fix for Drupal 'Social Share Counter' module - Facebook Counter Not Working

| Drupal Development | 18 seen

I have been using Drupal's Social Share counter module for some time already. It worked great until recently it stopped and all posts were showing 0 shares.

After a quick research on the modules issue page, I found the solution: Facebook share counter not working

Facebook has changed its API recently, so the URL http://graph.facebook.com/?id=URL, which is used by the module no longer works and the share counter is always 0.

There is also a patch provided to fix this issue:

diff --git a/sites/all/modules/contrib/social_share_counter/social_share_counter.inc b/sites/all/modules/contrib/social_share_counter/social_share_counter.inc
index cd85c09b4..48cf292da 100644
--- a/sites/all/modules/contrib/social_share_counter/social_share_counter.inc
+++ b/sites/all/modules/contrib/social_share_counter/social_share_counter.inc
@@ -1,5 +1,7 @@
 <?php
 
+define('FACEBOOK_API_URL', 'https://graph.facebook.com/?id=%&fields=og_object{engagement}&format=json');
+
 /**
  * @file
  * File contains functions for individual share count from all Social service.
@@ -11,10 +13,11 @@
  */
 function get_count_facebook($url) {
   $count = 0;
-  $response = _social_share_counter_parse("http://graph.facebook.com/?id=" . $url);
+  $url = str_replace('%', $url, FACEBOOK_API_URL);
+  $response = _social_share_counter_parse($url);
   $result = json_decode($response);
-  if (isset($result->share)) {
-    $count = formatNumberAbbreviation($result->share->share_count);
+  if (isset($result->og_object->engagement->count)) {
+    $count = formatNumberAbbreviation($result->og_object->engagement->count);
   }
 
   return $count;

After patching social share counter was back and counting. Hope it helps

 

Latest articles

Berlin Brandenburg Airport

In April 2026, I had my first experience with Berlin Brandenburg Airport (BER) while flying the Riga–Berlin–Riga route with airBaltic. This was my first time using Berlin’s main international airport, and overall, it left a solid impression—modern, functional, and relatively easy to navigate. About a decade ago, I had the chance to travel through…

Germany |
Embedded thumbnail for Mumbai &amp; Goa / India Trip

Mumbai & Goa / India Trip

It has already become something of a tradition for us - escaping the cold during our daughter’s winter school break and trading grey skies for warmth, color, and a slower rhythm of life. Each year, we carve out about three weeks to leave Tbilisi behind and head somewhere sunnier. And more often than not, that “somewhere” turns out to be India.Our…

India |