エラーは、
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 = 配列();
$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":"リクエストで Authorization ヘッダーが提供されていません。Fitbit API への各呼び出しは OAuth である必要があります署名済み"}]}