title: How can I send POST data to a phantomjs script
body: <p>I am working with PHP/CURL and would like to send POST data to my phantomjs script, by setting the postfields array below:</p>
  
  <pre><code>    $ch = curl_init();
      curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
      curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)");               
      curl_setopt($ch, CURLOPT_POST, TRUE);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $postFieldArray);
      curl_setopt($ch, CURLOPT_URL, $url);
      $output = curl_exec($ch);
  </code></pre>
  
  <p>The problem is I don't know how to parse a POST request inside the phantomjs script. I am using the webserver module to expose the script.</p>
  
  <p>I suspect <a href="https://github.com/benfoxall/phantomjs-webserver-example/blob/master/server.js" rel="nofollow">https://github.com/benfoxall/phantomjs-webserver-example/blob/master/server.js</a> may have the answer, but I don't know enough javascript to tell whether post variables are  being parsed:</p>
  
  <pre><code>var service = server.listen(port, function(request, response) {
  
  if(request.method == 'POST' &amp;&amp; request.post.url){
      var url = request.post.url;
  
      request_page(url, function(properties, imageuri){
          response.statusCode = 200;
          response.write(JSON.stringify(properties)); 
          response.write("\n");   
          response.write(imageuri);
          response.close();
      })
  </code></pre>
  
  <p>Can someone show me how to parse a POST request here?</p>