[link_popup id='2715' link_text='Click to open popup' name='Main Pop Up']
Digital strategies generating customer growth and revenue.

30%* off! Big Savings For Your Small Business!

Reading Time: 3 minutes

It’s hard to believe a few years has passed since I wrote the tutorial about how to use Facebook’s Graph API 2.X to retrieve the count for a given URL’s likes, shares, and comments.

I was informed a few days ago that my seamless solution for displaying the total count for likes, shares, and comments is dead in the water and no longer works.

Well, I guess this means we’re all in the dark now since Facebook’s most recent API upgrade doesn’t allow for such desired functionality, right?

Wrong! Facebook’s latest upgrade to Graph API actually requires a more secure approach to retrieving data. Allow Graph API 2.X was easy to use when attempting to retrieve engagement activity, it was less secure.

Facebook’s Graph API 3.X is more secure and robust, although you’ll have to do a bit more math to retrieve the overall total likes for a given url or object.

In today’s “upgrade” tutorial, I’ll build upon the codebase I shared with you in my last tutorial.

But first things first. You must create an App to be able to use the Facebook Graph API. Head on over to Facebook for Developers.

Once you create your app and it’s approved, then you’ll need the App ID and App Secret. Be sure not to share the App Secret publicly.

Once you have an App ID and App Secret, you’re now ready to do a bit of reading up in the Graph API Reference for developers. Read about how to retrieve engagement activity for a given URL external to Facebook.

This given reference page shares different HTTP, PHP, JavaScript, Android, iOS and Graph API Explorer examples to make requests to retrieve and read data.

In the aforementioned reference for the URL, the page also shares the necessary permissions needed as well as the following fields and their respective key-pair values that can be returned when a request is made.

  • app_links – AppLinks data associated with this URL, if available
  • id – the URL itself
  • engagement – counts of different ways (i.e., reaction_count, comment_count, share_count, comment_plugin_count) people interacted with the URL.
  • og_object – The Open Graph Object that is canonically associated with this URL

Making Facebook Graph API Call to Retrieve Engagement Activity

To make the request to retrieve engagement activity for a URL, I’m modifying the previous code base. Really, the first 4 and last 4-6 lines of code are modified.

For the sake of time, I’ve included the code below. Be sure to replace your-app-id, your-app-secret and the first url variable’s value with the desired URL.

Once you do this, save the code in a php file on a web server that supports PHP, and view the file using a web browser. It should display the following:

Facebook Graph API 3.X to Retrieve Engagement Activity

And for those that thought Facebook’s Graph API 3.X upgrade buried the ability and functionality to retrieve engagement activity for URLs and web pages, you better think again, because you have another think coming.

For now, tune in and watch my quick tutorial as I explain and walk through the codebase and process in its entirety.

In closing, please don’t hesitate to send me questions or comments about any of the topics I’ve mentioned in this tutorial. Thanks and that’s all for now!

Please subscribe to my YouTube channel to receive tutorial alerts.

Meet Alvin Brown

He's an experienced and passionate serial entrepreneur, founder and publisher of Kickstart Commerce. Alvin possesses a great love for startups dominating their market using profitable digital strategies for greater commerce.

2 Responses to How to Use Facebook Graph API 3.X to Retrieve Engagement Activity

Leave a Reply

Your email address will not be published. Required fields are marked *

*



Browse by topic

THE DAILY SCOOP

Subscribe today and receive instant access to need-to-know Domain marketing strategies, auctions, promo codes and other FREE resources.

Enter your email, and you're on your way!

Unsubscribe at any time.