我想每次在页面上点击Facebook Like按钮时运行MySQL查询。我已经知道FB.Event.subscribe('edge.create', function(response) {}
被用来执行点击Like按钮时的操作。我的问题是,我不知道Javascript/AJAX。我可以使用哪些简单的Javascript/AJAX代码,但是只在FB.event的大括号内运行下面的MySQL查询?我的理解是,我可能需要获得某种JQuery库,这很好。当点击Facebook Like按钮时,使用Ajax通过PHP运行MySQL查询
由于提前,
约翰
页面上的相关代码:
<script src="http://connect.facebook.net/en_US/all.js"></script>
<?php
session_start();
$uid = $_SESSION['loginid'];
$_SESSION['submissionid'] = $submissionid;
echo '<div id="fb-root"></div>';
echo "<script>
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
echo '</script>";
echo '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">';
echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="" send="true" layout="button_count" width="450" show_faces="false" font="arial"></fb:like>';
MySQL查询我想每一个Like按钮被点击时运行:
mysql_query("INSERT INTO fblikes VALUES (NULL, '$submissionid', '$uid', NULL)");
谢谢...我在哪里把这个updateMe()函数? – John 2011-06-17 00:46:55
''script type =“text/javascript”> function ...'它应该和当然按钮在同一个文件中。 – RRStoyanov 2011-06-17 00:54:22
这将与http://connect.facebook.net/en_US/all.js库一起工作吗? – John 2011-06-17 01:06:46