I need to convert this "normal" curl string to php curl. This command is tested to work from shell:
curl -XPUT http://foo/monitors/1.json -d "Monitor[Name]=test1"
I have looked at a lot of tuts and examples, but my attempts so far have been fruitless. Here's the latest i tried:
$data = array("Name" => "test1");
$payload = json_encode( array( "Monitor"=> $data ) );
$url = 'hxxp://foo/monitors/1.json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS,$payload);
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch)
also the json I'm trying to put to is formatted like this:
{"monitor":{"Monitor":{"Id":"1","Name":"test","Type":"Remote","Funct.....
thanks
*Updated with more current info