php没有得到我从curl发送的json值

时间:2012-02-25 21:58:50

标签: php json curl urldecode

curl -i -X POST -d'json = {“Amount”:1000,“idPlayers”:1}'http://www.myurl.com/updateamount.php

我的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;

1 个答案:

答案 0 :(得分:1)

尝试更改以阅读发布数据并使用正确的名称:

$json = urldecode($_POST['json']);