title: How to use curl put in php with json?
body: <p>I need to convert this "normal" curl string to php curl. This command is tested to work from shell:</p>
  
  <pre><code>curl -XPUT http://foo/monitors/1.json -d "Monitor[Name]=test1"
  </code></pre>
  
  <p>I have looked at a lot of tuts and examples, but my attempts so far have been fruitless. Here's the latest i tried: </p>
  
  <pre><code>$data = array("Name" =&gt; "test1");
  $payload = json_encode( array( "Monitor"=&gt; $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) 
  </code></pre>
  
  <p>also the json I'm trying to put to is formatted like this:</p>
  
  <pre><code>{"monitor":{"Monitor":{"Id":"1","Name":"test","Type":"Remote","Funct.....
  </code></pre>
  
  <p>thanks</p>
  
  <p>*Updated with more current info</p>