【发布时间】:2015-02-20 22:32:37
【问题描述】:
我正在尝试通过 basecamp api 刷新 access_tokens。但是我遇到了一个奇怪的错误。
cURL 请求在 POSTMAN 上运行良好(选项卡:form-data)。但是我尝试了 PHP 中 cURL 的所有配置,但无法使其工作。
这是我正在使用的代码:
$refresh_token = func_to_get_refresh_token();
$data='redirect_uri=xxxxmyredirecturixxxx&client_id=xxxxmyclientidxxx&client_secret=xxxxmyclientsecretxxxxx&refresh_token='.$refresh_token.'&type=refresh';
curl_setopt($ch, CURLOPT_URL, 'https://launchpad.37signals.com/authorization/token');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$resp = curl_exec($ch);
我正在从 Basecamp 服务器返回以下结果:
* upload completely sent off: 448 out of 448 bytes
< HTTP/1.1 400 Bad Request
* Server nginx is not blacklisted
< Server: nginx
< Date: Mon, 09 Feb 2015 08:05:51 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Status: 400 Bad Request
< X-Request-Id: aaec3a6c61eb5e603672a7a2e004ea7a
< Cache-Control: no-cache
< Set-Cookie: _launchpad_session=BAh7BiIPc2Vzc2lvbl9pZCIlOTEwZTEyOTY0N2M1ZDMxNjM4YjJlZTI2MmRjODE0MTI%3D--7ba9863975db8a7d2c97425300abab8d5405c17a; path=/; HttpOnly; secure
< X-Frame-Options: SAMEORIGIN
< X-Runtime: 0.011202
< Strict-Transport-Security: max-age=31536000
< X-UA-Compatible: IE=Edge,chrome=1
<
* Connection #0 to host launchpad.37signals.com left intact
{"error":"authorization_expired"}
我已经尝试了几乎所有可以在 stackoverflow 上找到的 cURL 配置。
我们将不胜感激您的帮助。
【问题讨论】: