title: Querying API through Curl/PHP
body: <p>I'm looking at the Parse.com REST API and making calls using the Curl wrapper PHP uses.</p>
  
  <p>Raw Curl code(works):</p>
  
  <pre><code>curl -X GET \
    -H "X-Parse-Application-Id: myApplicationID" \
    -H "X-Parse-REST-API-Key: myRestAPIKey" \
    https://api.parse.com/1/classes/Steps
  </code></pre>
  
  <p>PhP code(works):</p>
  
  <pre><code>$ch = curl_init('https://api.parse.com/1/classes/Steps');
  
  curl_setopt($ch,CURLOPT_HTTPHEADER,array('X-Parse-Application-Id: myApplicationID',
      'X-Parse-REST-API-Key: myRestAPIKey',
      'Content-Type: application/json'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  curl_exec($ch);
  curl_close($ch);
  </code></pre>
  
  <p>Thats good and dandy, but now when I try to add a query constraint:</p>
  
  <p>Raw Curl code(works):</p>
  
  <pre><code>curl -X GET \
    -H "X-Parse-Application-Id: myApplicationID" \
    -H "X-Parse-REST-API-Key: myRestAPIKey" \
    -G \
  --data-urlencode 'where={"steps":9243}' \
  https://api.parse.com/1/classes/Steps
  </code></pre>
  
  <p>Alas, we ultimately arrive at my question- What is the php analogue to the above code?</p>
  
  <p>PHP code(does not work):</p>
  
  <pre><code>$ch = curl_init('https://api.parse.com/1/classes/Steps');
  
  $query = urlencode('where={"steps":9243}');
  
  curl_setopt($ch,CURLOPT_HTTPHEADER,array('X-Parse-Application-Id: myApplicationID',
      'X-Parse-REST-API-Key: myRestAPIKey',
      'Content-Type: application/json'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
  
  curl_exec($ch);
  curl_close($ch);
  </code></pre>
  
  <p>Error response:</p>
  
  <pre><code>Object ( [code] =&gt; 107 [error] =&gt; invalid json: where%3D%7B%22steps%22%3A9243%7D )
  </code></pre>