我試圖將Facebook Credits作爲使用as3-sdk的支付方式進行整合。我設法獲得「earn_credits」和「buy_credits」的工作。然而,第三個也是最重要的選項「buy_item」沒有顯示薪酬對話框。以某種方式連接到callback.php似乎是問題的原因。注意:我在我的應用程序設置中輸入了回調網址,所以我沒有忘記。我使用Facebook Developer文檔中的示例php文件。集成Facebook Credits與AS3-SDK
這是我的as3代碼。
public static function buyItem():void
{
var theAction:String = "buy_item";
var order_info:Object = { "item_id":"1a" };
var jOrder:String = JSON.encode(order_info);
var data:Object = {
action:theAction,
order_info:jOrder,
dev_purchase_params: {"oscif":true}
};
Facebook.ui("pay", data, purchaseCallback);
}
我認爲json編碼可能是問題,但我不確定。
我使用Facebook的開發者文檔(節選)的例子php文件:
<?php
$app_secret = '***********************';
// Validate request is from Facebook and parse contents for use.
$request = parse_signed_request($_POST['signed_request'], $app_secret);
// Get request type.
// Two types:
// 1. payments_get_items.
// 2. payments_status_update.
$request_type = $_POST['method'];
// Setup response.
$response = '';
if ($request_type == 'payments_get_items') {
// Get order info from Pay Dialog's order_info.
// Assumes order_info is a JSON encoded string.
$order_info = json_decode($request['credits']['order_info'], true);
// Get item id.
$item_id = $order_info['item_id'];
// Simulutates item lookup based on Pay Dialog's order_info.
if ($item_id == '1a') {
$item = array(
'title' => '100 some game cash',
'description' => 'Spend cash in some game.',
// Price must be denominated in credits.
'price' => 1,
'image_url' => '**********************/banner1.jpg',
);
// Construct response.
$response = array(
'content' => array(
0 => $item,
),
'method' => $request_type,
);
// Response must be JSON encoded.
$response = json_encode($response);
}
任何幫助,真是感激。
非常感謝!我注意到,你沒有使用json編碼的字符串,但fb開發者頁面中的creditsbacks callback.php期望order_info是一個json編碼的字符串。你知道一個callback.php例子aw/o的json代碼嗎? – TicketToRide 2012-04-08 13:22:45
對不起,我不得不更多地研究它......就像我說的,這不是我的解決方案,我甚至沒有嘗試過我。 – 2012-04-08 14:30:20