我跟隨official tutorial實施FB積分,但它不起作用。Facebook積分實施有什麼問題
我加入警報報表,以確保代碼執行,從警報消息,我相信沒有JS錯誤,FB.ui被調用。我在回調函數中也有警報消息,但沒有收到響應。
我打破我的頭,因爲5小時弄清楚什麼是錯的代碼。有人可以幫幫我嗎。
上的應用程序附加信息:
- 畫布應用程序(啓用沙盒模式)
- 未公佈
- 沒有註冊公司。 FB說我以後可以做,所以我剛剛設置了國家。我還沒有註冊,因爲我需要到哪個銀行帳戶資料,我需要放棄,因爲FB不會允許改變它(從界面)的結論
這裏是buy.php
<?php
include_once '/Config.php';
include_once '/fb-sdk/facebook.php';
?>
<html>
<head>
<title>My Facebook Credits Page</title>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '<?php echo Config::$appId?>',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://localhost/buy.php', // channel.html file
oauth : true // enable OAuth 2.0
});
var callback = function(data) {
if (data['order_id']) {
alert('called back');
return true;
} else {
//handle errors here
alert('some error');
return false;
}
};
function placeOrder(){
alert('in placeOrder()');
var order_info = 'myorderinfo';
alert('creating obj');
var obj = {
method: 'pay',
order_info: order_info,
action: 'buy_item',
dev_purchase_params: {'oscif': true}
};
alert('calling ui');
FB.ui(obj, callback);
}
</script>
<input type="button" value="post" onclick="postFeed()" />
<input type="button" value="Buy" onclick="placeOrder()" />
</body>
</html>
如果您發現警報電話,我在爲了獲得警報消息
-
'在placeOrder()'
- '創建OBJ'
- '調用FB.ui'
有回調函數太警報消息,但他們沒有被稱爲
要確保
function postFeed(){
alert('in postFeed()');
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
這是工作的罰款和寶FB是inited妥善我已經實現了新聞發佈功能,並呼籲從「postFeedback」 click事件在我的牆上
我已經使用在https://developers.facebook.com/docs/authentication/signed_request/
給出的例子還實施了callback.php和Sting飼料是的,我已經配置了應用程序的設置適當
callback.php
<?php
include_once 'Config.php';
mysql_connect('localhost','root','');
mysql_select_db("precious_world");
//var_dump($_REQUEST);
//dump the request into the db
$request = join(':', $_REQUEST);
$request = mysql_real_escape_string($request);
$query = "insert into fbcredits_callback(data)values('$request')";
$result = mysql_query($query);
$fb_signed_req = $_REQUEST['signed_request'];
echo parse_signed_request($signed_request, Config::$appSecret);
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
?>
我在這個文件中有一些額外的代碼來轉儲整個請求以跟蹤請求
aaaaaw所以我就在主持人的主持下。爲此。我會檢查 – 2012-03-08 17:05:40
所以爲了檢查訂單的事情,我不得不提到實時網址?沒有別的辦法嗎? – Volatil3 2012-03-21 10:38:33
不,您可以使用另一個URL,但必須通過Facebook服務器訪問。 – Gabriel 2012-06-21 07:32:16