用户在我的网站中共享链接后是否可以更新数据库?
例如,如果他们分享链接,他们的帐户将获得一些积分。
我怎样才能确保他们真正分享 Facebook 的链接,而不仅仅是点击分享然后关闭弹出窗口......
我对 facebook 不熟悉,刚才尝试 google 但仍然没有找到答案......
谢谢。
Edit:
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
type="text/javascript">
</script>
<a name="fb_share" type="button" share_url="script2.php?id=XXX">
更新(2013 年 8 月 21 日):自本文最初发布以来,Facebook 的 api 已发生变化。追踪点赞的方式还是一样的(阅读下面的原始答案),但共享按钮的状态已更改。
弃用消息/信息。在文档中的任何地方都不再可见,但可以在this bug。分享按钮似乎仍然可以使用this doc。但 Facebook 没有直接的方法来跟踪分享。我也不知道有任何跟踪股票的黑客行为。
原答案:
来自 Facebook 文档:这个链接.
“分享”按钮已被弃用,取而代之的是“点赞”按钮,并且将不再受支持。
请尽可能使用“赞”按钮,为您的应用带来最大流量。
所以我会告诉你如何为“赞”按钮做到这一点:
首先使用JavaScript SDK
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
// you can subscribe to events here
// edge.create event is fired only when the user likes (which means that the wall post has already happened, when the like button was clicked)
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
// you can do some ajax call to your backend and update your database
}
);
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
页面中的某个位置包含“赞”按钮
<fb:like href="http://example.com/fblike/"
send="true" width="450" show_faces="false"
>
</fb:like>
您还可以更改“喜欢”按钮中显示的单词,从“喜欢”更改为“推荐”,您应该尝试从此自动生成“喜欢”按钮代码link.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)