-1
發送捲曲-i -X POST -d 'JSON = { 「金額」:1000, 「idPlayers」:1}' http://www.myurl.com/updateamount.phpPHP不獲取JSON值I從捲曲
我的PHP代碼:
<?php
$json = urldecode($_GET['jsonSendData']);
$json = str_replace("\\", "", $json);
$data = json_decode($json, true);
// if i hard code it here it works fine, but need from a post from curl
//$json = '{"Amount":1000,"idPlayers":1}';
$data = json_decode($json, true);
echo "json = ", $json;
$amount = mysql_real_escape_string($data['Amount']);
$id = mysql_real_escape_string($data['idPlayers']);
echo "Amount = ",$amount;
return;
奏效的感謝!我嘗試過,但不正確! – 2012-02-25 22:12:31
我的Xcode人認爲我可以像下面這樣做,所以我們不必發送'json'值。但它沒有任何想法? $ json = urldecode($ _ POST ['json']); \t $ json = str_replace(「\\」,「」,$ json); \t $ data = json_decode($ json,true); // $ amount = json_decode($ _ POST ['Amount']); // $ player_id = json_decode($ _ POST ['idPlayers']); – 2012-02-26 23:55:57