-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 に答える