Ire*_*ing 3 php facebook facebook-graph-api
一旦用户在我的网站中共享链接,是否可以更新数据库?
例如,如果他们共享链接,将会向他们的帐户授予一些积分.
我怎样才能确保他们真正分享到Facebook的链接,而不仅仅是点击共享然后关闭弹出窗口......
我不熟悉facebook,刚刚尝试谷歌,但仍未找到答案......
谢谢.
编辑:
<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">
Run Code Online (Sandbox Code Playgroud)
更新(2013年8月21日):Facebook的api自最初发布以来已发生变化.跟踪喜欢的方式仍然相同(请阅读下面的原始答案),但共享按钮的状态已更改.
弃用消息/信息.在文档中的任何地方都不再可见,但可以在此错误中看到.根据此文档,共享按钮似乎仍然可用.但Facebook没有直接跟踪分享的方式.我也不知道跟踪股票的任何黑客行为.
原始答案:
不推荐使用"共享"按钮以支持"赞"按钮,并且将不再支持"共享"按钮.请尽可能使用"赞"按钮来为您的应用带来最大流量.
所以我会告诉你如何为类似的按钮做到这一点:
<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>
Run Code Online (Sandbox Code Playgroud)
<fb:like href="http://example.com/fblike/"
send="true" width="450" show_faces="false"
>
</fb:like>
Run Code Online (Sandbox Code Playgroud)
您也可以更改类似按钮中显示的单词,从建议开始,您应该尝试从此链接自动生成类似按钮代码.