title: php file get contents with post data
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8535820/drupal-login-via-rest-server">Drupal login via Rest server</a>  </p>
  </blockquote>
  
  
  
  <p>I have been using this code for file get contents with post data but receiving an error </p>
  
  <pre><code>Warning: file_get_contents(http://50.116.19.49/rest/user/login.json): failed to open  
  stream: HTTP request failed! HTTP/1.0 406 Not Acceptable: Unsupported request content type 
  application/x-www-form-urlencoded in C:\xampp\htdocs\post.php on line 20
  </code></pre>
  
  <p>My code is </p>
  
  <pre><code>&lt;?php
  
  $postdata = http_build_query(
  array(
      'var1' =&gt; 'myuser',
      'var2' =&gt; 'pwd'
  )
  );
  
  $opts = array('http' =&gt;
  array(
      'method'  =&gt; 'POST',
      'header'  =&gt; 'Content-type: application/x-www-form-urlencoded',
      'content' =&gt; $postdata
  )
  );
  
  $context  = stream_context_create($opts);
  
  $result = file_get_contents('http://50.116.19.49/rest/user/login.json', false,    
  $context);
  
  ?&gt;
  </code></pre>
  
  <p>Can anybody help in this Thanks in advance.</p>