Php 不支持HTTP/1.1 505 HTTP版本

Php 不支持HTTP/1.1 505 HTTP版本,php,apache,http,curl,paypal,Php,Apache,Http,Curl,Paypal,我试图实现PayPal未来的支付服务器(),但我的服务器平台遇到了问题 每当我尝试使用以下代码进行卷曲时: $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&am

我试图实现PayPal未来的支付服务器(),但我的服务器平台遇到了问题

每当我尝试使用以下代码进行卷曲时:

$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&response_type=token&redirect_uri=urn:ietf:wg:oauth:2.0:oob&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);
我得到以下回应:

HTTP/1.1 505 HTTP Version Not Supported
Server: Apache-Coyote/1.1
Date: Wed, 22 Oct 2014 21:30:35 GMT
Connection: close
是什么导致了这个问题,我如何配置我的服务器来支持这个curl代码

谢谢

更新:新代码

$headers = array(
    'Content-Type: application/x-www-form-urlencoded'
);
$fp = fopen("db.txt","w");
$data = array(
    "grant_type" => "authorization_code",
    "response_type" => "token",
    "redirect_uri" => "urn:ietf:wg:oauth:2.0:oob",
    "code" => $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);
新错误消息:

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&CalThreadId=XXXXX&TopLevelTxnStartTime=149489a7468&Host=slcidensectoken3043a.slc.paypal.com&pid=XXXXX Content-Language: * Date: Sat, 25 Oct 2014 18:38:41 GMT Connection: close Content-Type: text/xml Content-Length: 0 Connection: close

不要将所有参数都放在get字符串中,而是将它们放在一个数组中,并使用http\u build\u query创建get字符串。我已经看到了这个问题,当有一些字符应该是url_编码的,但不是。浏览器通常会以透明的方式处理这个问题,而curl则不会。您还可以尝试更改http版本,看看这是否有帮助。有一个您可以尝试的CURLOPT_HTTP_版本设置。我应该将其设置为2.0吗?curl_setop($ch,CURLOPT_HTTP_VERSION,curl_HTTP_VERSION_2_0);我建议1.0,但你可以尝试任何一种。最快的方法是更改它,运行它并查看结果。好的,我尝试了1.0、1.1、2.0和NONE,错误没有改变