Wednesday, 9 March 2016

Facebook Likes Count with PHP

Hi

Get Facebook Likes Count with PHP


STEP 1 :First we make a function that will pass one parameter and that parameter is our link.

function fb_count($url)
{
}


STEP 2 : Then under this function first we make a query and ask it to SELECT share_count, like_count and comment_count from a table named link_stat. Obviously we need a KEY for for it so our Link or URL will be the KEY for this query.

$fql = "SELECT share_count, like_count, comment_count ";
$fql .= " FROM link_stat WHERE url = '$url'";


STEP 3 : Then we use Facebook API to pass above Query. After passing this query we will get our response in JSON.

$fqlURL = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql);

STEP 4 : When facebook response us in JSON we need to decode that JSON it can be through Buil-in function json_decode().

$response = file_get_contents($fqlURL);
return json_decode($response);

STEP 5 : Now it’s time to pass our Link or URL to get likes, shares and comments. Simply I use finction fb_count() and provide it a parameter as a Link or URL

$fb = fb_count('our link set here');


Now we have to echo that response.


1 - For facebook Shares Count 

            echo $fb[0]->share_count;

2 - For facebook Like Count 

            echo $fb[0]->like_count;

3 - For facebook Like Count 

            echo $fb[0]->comment_count;

Enjoy..........  :)


Related Articles

23 comments:

  1. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!
    ปั้มผู้ติดตาม

    ReplyDelete
  2. Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.
    해외축구중계

    ReplyDelete
  3. Great post full of useful tips! My site is fairly new and I am also having a hard time getting my readers to leave comments. Analytics shows they are coming to the site but I have a feeling “nobody wants to be first”.
    คาสิโนออนไลน์ครบวงจรที่สุด

    ReplyDelete
  4. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.
    เว็บสล็อตmegawin

    ReplyDelete
  5. Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.
    เว็บเกมยิงปลาออนไลน์

    ReplyDelete
  6. I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.
    xtremejackets

    ReplyDelete
  7. I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job!
    satta king

    ReplyDelete
  8. Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here.
    youtube to mp4 downloader

    ReplyDelete
  9. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    vps brasileiro

    ReplyDelete
  10. My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more!
    metal garage

    ReplyDelete
  11. Should there be another persuasive post you can share next time, I’ll be surely waiting for it.
    Diamanten kaufen Kassel

    ReplyDelete
  12. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.
    เว็บแทงบอลบนมือถือฝากขั้นต่ำ100

    ReplyDelete
  13. Should there be another persuasive post you can share next time, I’ll be surely waiting for it.
    bulk cd duplication

    ReplyDelete
  14. Should there be another persuasive post you can share next time, I’ll be surely waiting for it.
    Siddhasana steps

    ReplyDelete
  15. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    Wb77vip.com

    ReplyDelete
  16. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    Versicherung Kassel

    ReplyDelete
  17. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    lion breath carts

    ReplyDelete
  18. Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!. แอ พ สล็อต

    ReplyDelete
  19. I feel a lot more people need to read this, very good info!
    webtraffic panel

    ReplyDelete
  20. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    hire a hacker urgently

    ReplyDelete
  21. I feel a lot more people need to read this, very good info!
    คาสิโนออนไลน์

    ReplyDelete

Prompt Web Solution. Powered by Blogger.