広告のコメントが作成されたときに、小さな通知機能を作成しようとしています。デスクトップ版では問題なく動作しますが、モバイル版でFB.Event.subscribe
は起動しません。
私はこのコードを持っています:
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'XXXX'
channelUrl : 'http://www.xxx.dk/channel.php',
status : true,
xfbml : true
});
FB.Event.subscribe('comment.create',
function (response) {
$.ajax({
url: 'http://www.xxx.dk/notify.php',
type: 'POST',
data: { aid: {$viewad.aid} },
success: function(data) { },
error: function(data) { }
});
});
};
(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);
}());
</script>
fbAsyncInit と FB.init の両方が正しく起動されています! alert("fired") を入力すると、そのアラートが表示されますが、FB.Event.subscribe 内では表示されません。
channel.php には次のものが含まれます。
<?php
$cache_expire = 60*60*24*365;
header("Pragma: public");
header("Cache-Control: max-age=".$cache_expire);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');
?>
<script src="//connect.facebook.net/en_US/all.js"></script>