我正在尝试在 Facebook 应用程序上实施 TrialPay/Offerwall/Dealspot。在他们的文档中,他们举例说明了他们发送给您的 JSON 的样子:
{"order_id":9006316682257,"buyer":409697,"app":107032282669135,"receiver":409697,
"amount":1,"time_placed":1322622026,"update_time":1322622027,"data":"",
"items":[{"item_id":"0","title":"3 Fred Currency","description":"Make it rain!",
"image_url":"http:\/\/external.ak.fbcdn.net\/safe_image.php?d=AQDldsPcWsejAJdC&url=http\u00253A\u00252F\u00252Fwww.etftrends.com\u00252Fwp-content\u00252Fuploads\u00252F2011\u00252F10\u00252Fcurrency-trading.jpg",
"product_url":"","price":1,"data":"{\"modified\":{\"product\":\"URL_TO_APP_CURR_WEBPAGE\",
\"product_title\":\"Fred Currency\",\"product_amount\":3,\"credits_amount\":1}}"}],"status":"placed"}
他们说如果你 json_decode 它作为一个数组你应该得到这个:
Array (
[order_id] => 9006316682257
[buyer] => 409697
[app] => 107032282669135
[receiver] => 409697
[amount] => 1
[time_placed] => 1322622026
[update_time] => 1322622027
[data] =>
[items] => Array (
[0] => Array (
[item_id] => 0
[title] => 3 Fred Currency
[description] => Make it rain!
[image_url] => http://external.ak.fbcdn.net/safe_image.php?d=AQDldsPcWsejAJdC&url=http%3A%2F%2Fwww.etftrends.com%2Fwp-content%2Fuploads%2F2011%2F10%2Fcurrency-trading.jpg
[product_url] =>
[price] => 1
[data] => {"modified":{"product":"URL_TO_APP_CURR_WEBPAGE","product_title":"Fred Currency","product_amount":3,"credits_amount":1}}
)
)
[status] => placed
)
但事实并非如此,数据实际上如下所示:
[data] => "{"modified":{"product":"URL_TO_APP_CURR_WEBPAGE","product_title":"Fred Currency","product_amount":3,"credits_amount":1}}"
字符串中的 JSON 导致它是无效的 JSON。有没有一种简单的方法可以删除这些引号?