How can I store the number of facebook Likes of a particular url in my own database?

試著忘記壹切 提交于 2019-12-12 05:39:12

问题


Lets say I am having 5 news articles on my website and 2 registered users. Each news article is having an FB like button. I want to insert the username and article name in my own database whenever the user likes one of the articles. How can this be done?

If it would have been a normal submit button (instead of FB like button) then i would have simply added an onclick event to call a javascript function which in turn sends an ajax request to a php file which inserts the row in the database with the required field.

Can I add an onClick event with FB like button? if not then is there an alternative?


回答1:


A slightly hack-y way to go about it would be to attach an onclick event handler to the iframe container to trigger an event whenever a user clicks like on page.

I haven't worked with the API that much, but can't you use this: edge.create -- fired when the user likes something (fb:like)? http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/



来源:https://stackoverflow.com/questions/5544370/how-can-i-store-the-number-of-facebook-likes-of-a-particular-url-in-my-own-datab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!