title: Add document to Apache Solr via PHP cURL
body: <p>I don't know what I have done wrong. The record does not get added.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$ch = curl_init("http://127.0.0.1:8983/solr/collection1/update/json?commit=true");
  
  $data = array(
      "add" =&gt; array( "doc" =&gt; array(
          "id"   =&gt; "HW132",
          "name" =&gt; "Hello World"
      ))
  );
  $data_string = json_encode($data);
  
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_POST, TRUE);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  
  $response = curl_exec($ch);
  </code></pre>
  
  <p>And here is the response that I get from Solr:</p>
  
  <pre><code>{"responseHeader":{"status":0,"QTime":4}}
  </code></pre>