title: Parse's REST API and PHP Curl requests - how to
body: <p>I am using the excellent <a href="https://parse.com/">Parse</a> as a data store, but need to access it through PHP (as a perhaps irrelevant bit of detail - I am having to access it through PHP in order for Facebook scrapers to recognise dynaically generated  tags on my page).</p>
  
  <p>Parse have a Rest API, and basic instructions on how to use them. For example, to retrieve an object:</p>
  
  <blockquote>
    <p>curl -X GET \<br>
    -H "X-Parse-Application-Id: [My application ID]" \<br>
    -H "X-Parse-REST-API-Key: [My Parse Rest API key]" \<br>
     <a href="https://api.parse.com/1/classes/moods/">https://api.parse.com/1/classes/moods/</a></p>
  </blockquote>
  
  <p>Unfortunately, I have no idea how to integrate this with PHP Curl examples I've seen online. I gather:</p>
  
  <blockquote>
    <p>curl_setopt($ch, CURLOPT_USERPWD,</p>
  </blockquote>
  
  <p>..might be involved. As might:</p>
  
  <blockquote>
    <p>curl_setopt($ch, CURLOPT_URL, $Url);</p>
  </blockquote>
  
  <p>but I could be way off. I am really sorry to not be able to figure this out myself - but I think this is still a valid question as it is very confusing to those who haven't used Curl/PHP before. Basically - I'm looking for information as basic as where to put the quoted example from the Parse docs...</p>
  
  <p>Thanks in advance</p>
  
  <p>EDIT:</p>
  
  <p>Hey all, here is the solution as I configured it. Thanks to debianek for getting me going in the right direction.</p>
  
  <pre><code>if ($_GET['id']) {
  $imageId = $_GET['id']; 
  MyApplicationId = '[ID]';
  $MyParseRestAPIKey = '[API Key]';
  $url = 'https://api.parse.com/1/classes/images/'.$imageId;
  
  $headers = array(
      "Content-Type: application/json",
      "X-Parse-Application-Id: " . $MyApplicationId,
      "X-Parse-REST-API-Key: " . $MyParseRestAPIKey
  );
  
      $handle = curl_init(); 
  curl_setopt($handle, CURLOPT_URL, $url);
  curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  
      $data = curl_exec($handle);
  curl_close($handle);
  
  $array = json_decode($data);
  
  $title =  $array-&gt;title;            
  </code></pre>
  
  <p>..and so on. Hope that helps.</p>