-1

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

My php code:

<?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;
John Carter
  • 53,924
  • 26
  • 111
  • 144

1 Answers1

1

Try to change to read post data and using the correct name:

$json = urldecode($_POST['json']);
Emil Vikström
  • 90,431
  • 16
  • 141
  • 175
  • My Xcode guy thinks i can do it like below so we don't have to send a 'json' value. but it doesn't work either any ideas? $json = urldecode($_POST['json']); $json = str_replace("\\", "", $json); $data = json_decode($json, true); // $amount = json_decode($_POST['Amount']); // $player_id = json_decode($_POST['idPlayers']); – Steve Green Feb 26 '12 at 23:55