ねえ、私は問題があります...
ユーザーが私の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 が取得されますが、db には何もありません。
誰が何が悪いのか教えてもらえますか?