嘿,我有一个问题...
我想当用户从我的 facebook 应用程序共享一个链接时,我将他的 id 输入我的数据库。
我分享链接的方式是通过我修改过的 facebook 对话框 javascript 示例
共享 javascript 代码
<script>
FB.init({appId: 'xxxx', channelUrl: 'xxxx', status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
document.getElementById('post').style.display = "none";
}
}
xmlhttp.open("POST","shared.php",true);
xmlhttp.send("id=xxx");
}
FB.ui(obj, callback);
}
</script>
PHP 代码
$con = mysqli_connect("xxxx","xxx","xxx","xxx");
if (!$con) {
die('Could not connect: ' . mysql_error());
};
mysqli_query($con, "INSERT INTO xxx (fb-id) VALUES (".$_POST['id'].")");
mysqli_close($con)
当我共享链接时,我得到了 post_id,但数据库中什么都没有?
谁能告诉我怎么了?