title: HTTP/1.1 505 HTTP Version Not Supported php curl
body: <p>I am attempting to implement PayPal's future payment server (<a href="https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/future_payments_server.md" rel="nofollow">https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/future_payments_server.md</a>), but am running into an issue with my server platform.</p>
  
  <p>Whenever I try to curl with this code:</p>
  
  <pre><code>$headers = array(
      'Content-Type: application/x-www-form-urlencoded'
  );
  
  $userpwd = "CLIENT_ID:SECRET";
  
  $ch = curl_init("https://api.paypal.com/v1/oauth2/token?grant_type=authorization_code&amp;response_type=token&amp;redirect_uri=urn:ietf:wg:oauth:2.0:oob&amp;code=".$code);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HEADER, $headers);
  curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
  $response = curl_exec($ch);
  curl_close($ch);
  </code></pre>
  
  <p>I get the following response:</p>
  
  <pre><code>HTTP/1.1 505 HTTP Version Not Supported
  Server: Apache-Coyote/1.1
  Date: Wed, 22 Oct 2014 21:30:35 GMT
  Connection: close
  </code></pre>
  
  <p>What could be causing this issue, and how do I configure my server to support this curl code?</p>
  
  <p>Thanks</p>
  
  <p>UPDATE: new code</p>
  
  <pre><code>$headers = array(
      'Content-Type: application/x-www-form-urlencoded'
  );
  $fp = fopen("db.txt","w");
  $data = array(
      "grant_type" =&gt; "authorization_code",
      "response_type" =&gt; "token",
      "redirect_uri" =&gt; "urn:ietf:wg:oauth:2.0:oob",
      "code" =&gt; $code
  );
  $query = http_build_query($data);
  $ch = curl_init("https://api.paypal.com/v1/oauth2/token?".$query);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HEADER, $headers);
  curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
  curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
  $response = curl_exec($ch);
  curl_close($ch);
  fwrite($fp,$response);
  fclose($fp);
  </code></pre>
  
  <p>new error message:</p>
  
  <pre><code>HTTP/1.1 500 Internal Server Error Server: Apache-Coyote/1.1 PROXY_SERVER_INFO: host=slcjavapapi3027a.slc.paypal.com;threadId=XXXX Paypal-Debug-Id: 679a3452b9bad Pragma: No-cache Cache-Control: no-cache Expires: Wed, 31 Dec 1969 16:00:00 PST SERVER_INFO: identitysecuretokenserv:v1.oauth2.token&amp;CalThreadId=XXXXX&amp;TopLevelTxnStartTime=149489a7468&amp;Host=slcidensectoken3043a.slc.paypal.com&amp;pid=XXXXX Content-Language: * Date: Sat, 25 Oct 2014 18:38:41 GMT Connection: close Content-Type: text/xml Content-Length: 0 Connection: close
  </code></pre>