我正在使用facebook credits api并使用其付费方式,以下是我的代码:
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
'appId' : '<?php echo $app_id; ?>',
'session' : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it
'status' : true, // check login status
'cookie' : true, // enable cookies to allow the server to access the session
'xfbml' : true // parse XFBML
});
// whenever the user logs in, we refresh the page
FB.Event.subscribe('auth.login', function() {
window.location.reload();
});
FB.Canvas.setAutoResize();
};
(function() {
FB_RequireFeatures(["CanvasUtil"], function() {
FB.CanvasClient.scrollTo(0, 0);
window.FB = null;
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
});
}());
</script>
<script type="text/javascript">
function placeOrder() {
var order_info = { "title":"Music Mood Points",
"description":"Get Music Mood Points to purchase avatars",
"price":"10",
"product_url":"abc"
};
// calling the API ...
var obj = {
method: 'pay',
order_info: order_info,
purchase_type: 'item'
};
FB.ui(obj, callback);
}
var callback = function(data) {
if (data['order_id']) {
writeback("Transaction Completed! </br></br>"
+ "Data returned from Facebook: </br>"
+ "<b>Order ID: </b>" + data['order_id'] + "</br>"
+ "<b>Status: </b>" + data['status']);
} else if (data['error_code']) {
writeback("Transaction Failed! </br></br>"
+ "Error message returned from Facebook:</br>"
+ data['error_message']);
} else {
writeback("Transaction failed!");
}
};
</script>
function writeback(str) {
$('.get_points').html(str);
}
</script>
这是点击按钮:
<input type="button" onclick="placeOrder();" value="GET More POINTS NOW" />
所以,当我点击按钮时,它会在facebook弹出窗口中显示:您的应用程序没有正确响应。
因此,代码或某些需要从应用程序设置中指定的内容中缺少某些内容。任何人都有任何想法。你能说出的任何小事都很受欢迎。
提前致谢
答案 0 :(得分:2)
当您下订单时,Facebook正在对您的服务器进行后端呼叫(到应用程序设置页面中设置的路径(在信用部分下)。
该错误意味着您的应用程序未正确回复该初始调用(实际上会发生两次)
参见http://developers.facebook.com/docs/creditsapi/ 更多包括后端的示例代码。