错误是,
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[errorType] => oauth
[fieldName] => n/a
[message] => No Authorization header provided in the request. Each call to Fitbit API should be OAuth signed
)
)
)
我正在使用 Oauth 库。我已经获得了用户令牌。
http://api.fitbit.com/1/user/23Q/profile.json?oauth_consumer_key=425e1234b8823e26485aa6&oauth_nonce=31f991c9b3e068c14adceddd9b862c0a&oauth_signature=R5oi4dHA6ztIIpdKheahYOy%2FeMQ%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1348821623&oauth_token=3405b4918d5d96a7b78885a98&oauth_version=1.0
我试过这个...
$url = http://api.fitbit.com/1/user/23Q2SP/profile.json;
$标头=数组();
$header[] = "授权:OAuth 3405b496578885a98";
$header[] = "Accept: ";
$header[] = "Cache-Control: no-cache";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en_US";
$header[] = "Pragma: no-cache";
$this->http_info = array();
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, $header);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
curl_setopt($ci, CURLOPT_HEADER, FALSE);
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
但是相同的错误 {"errors":[{"errorType":"oauth","fieldName":"n/a","message":"请求中没有提供授权标头。对 Fitbit API 的每次调用都应该是 OAuth签”}]}