PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 3, 2022

[FIXED] How do you get the total likes for a URL (Likes and Shares)?

 November 03, 2022     facebook, facebook-graph-api, facebook-like, facebook-social-plugins     No comments   

Issue

The "Likes" plugin that I've dropped on my page displays both the number of times the button has been directly clicked, as well as the number of times the page URL has been shared or the Like has been commented on.

When I use the Graph API to check out my object though, it only shows the number of direct "Like" clicks. Here is an example object:

{
   "id": "17678692xxxxxxx",
   "name": "The Dali Lama Returns",
   "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/161984_176786925772923_6855xxxxxxx.jpg",
   "link": "http://mysite.com/8/the-dali-lama-returns",
   "likes": 1,
   "app_id": 478xxxxxxx,
   "category": "Unknown",
   "is_published": true,
   "description": "The Dali Lama will speak, and we will listen.",
   "about": "The Dali Lama will speak, and we will listen.",
   "can_post": true
}

This means that after someone has clicked my like button, and written a comment about the like, the the button will display a count of "2", but my object will only display a count of one.

Is there a way to get the complete "Like" count that the button displays on my page?


Solution

I found two ways of doing this. The new way utilizing the graph api appears to be to be to use fql, as the following request shows:

https://graph.facebook.com/fql?q=SELECT url, normalized_url, share_count, like_count, comment_count, total_count, commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url='http://mysite.com/8/the-dali-lama-returns'

The old way, with the Rest API which is in the process of being deprecated:

link.getStats()

https://developers.facebook.com/docs/reference/rest/links.getStats/



Answered By - HelpMeStackOverflowMyOnlyHope
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,206,231

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing