-1

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;
4

1 回答 1

1

尝试更改以读取帖子数据并使用正确的名称:

$json = urldecode($_POST['json']);
于 2012-02-25T22:03:26.570 回答