我试图将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