2
我使用Facebook Credits的API,並使用其支付方法,下面是我的代碼:Facebook的信用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彈出窗口中顯示:您的應用程序沒有正確響應。
因此,代碼中缺少一些東西或需要從應用程序設置中指定某些東西。有沒有人有任何想法。任何你可以告訴的小事都會感激。
在此先感謝
耶,我得到了原因,這和你說的一樣,來自回調URL的錯誤迴應,我現在已經做到了,無論如何,謝謝 – Hafiz