我正在尝试实施PayPal未来的支付服务器(https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/future_payments_server.md),但我的服务器平台遇到了问题。
每当我尝试使用此代码时:
$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
可能导致此问题的原因,以及如何配置我的服务器以支持此卷曲代码?
由于
更新:新代码
$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