如何在自己的数据库中存储特定网址的Facebook点赞次数? [英] How can I store the number of facebook Likes of a particular url in my own database?

查看:92
本文介绍了如何在自己的数据库中存储特定网址的Facebook点赞次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我的网站上有5则新闻文章和2个注册用户.每个新闻文章都有一个类似FB的按钮.每当用户喜欢其中一篇文章时,我都希望在自己的数据库中插入用户名和文章名称.该怎么办?

如果这将是一个正常的提交按钮(而不是FB之类的按钮),那么我只需添加一个onclick事件即可调用javascript函数,该函数又将ajax请求发送到php文件,该文件将行插入到具有必填字段的数据库.

我可以添加带有FB like按钮的onClick事件吗?如果没有的话,还有其他选择吗?

http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

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?

解决方案

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/

这篇关于如何在自己的数据库中存储特定网址的Facebook点赞次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆