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

| Drupal Development | 19 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

Titanic Chaussee Hotel in Berlin

At the start of April 2026, we spent about six nights at Titanic Hotel Berlin (Chausseestraße 30). The trip was primarily work-related—my fiancée attended a conference in the translation industry—but it turned into a relaxed family stay, as I tagged along with our child during the Easter school break.The hotel sits in a convenient part of Berlin…

Germany |
Embedded thumbnail for Spring in Georgia: Morel Hunting, Gori Food Stop &amp; Stunning Gorijvari Views

Spring in Georgia: Morel Hunting, Gori Food Stop & Stunning Gorijvari Views

Shot at the end of April 2026, on a calm and lovely Sunday morning, this video started with a simple plan: go out and hunt for morels -  murķeļi. Spring, fresh air, perfect timing… everything looked right.But plans shifted quickly.After the first attempts turned up nothing, we didn’t push too hard — instead, we adapted. Rather than chasing…

Living in Georgia |