11-07-2015 14:26
11-07-2015 14:26
Hi,
I have the below code to get steps back.
function getSteps() { $requesturl = "https://api.fitbit.com/1/user/-/activities/steps/date/today/1m.json"; // Set the headers $headers = array(); $headers[] = "Authorization: Bearer ".$this->access_token; $headers[] = "Content-Type: application/x-www-form-urlencoded"; $this->activity = json_decode($this->sendRequest($headers, $requesturl)); return $this->activity; }
The response I get is :
object(stdClass)#8 (2) { ["errors"]=> array(1) { [0]=> object(stdClass)#9 (3) { ["errorType"]=> string(9) "not_found" ["fieldName"]=> string(3) "n/a" ["message"]=> string(46) "The API you are requesting could not be found." } } ["success"]=> bool(false) }
I think it has to do with the URL I am using. This is becuase I have another function that works. It uses the same code just changes the URL. Any ideas?
11-11-2015 17:52
11-11-2015 17:52
So to add a little more information...
If i change out the URL in the above code example to
https://api.fitbit.com/1/user/-/activities/date/today.json
It works, but if I copy and paste the below straight out of the documentation site...
https://api.fitbit.com/1/user/-/activities/steps/date/today/1m.json
I get the same error... Is this some kind of bug?
11-13-2015 10:58
11-13-2015 10:58
I'm not sure. This endpoint is working for me.
GET /1/user/-/activities/steps/date/today/1m.json HTTP/1.1 Authorization: OAuth oauth_consumer_key="REDACTED",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1447440942",oauth_nonce="516530977",oauth_version="1.0",oauth_token="REDACTED",oauth_signature="REDACTED" Host: api.fitbit.com X-Target-URI: https://api.fitbit.com Connection: Keep-Alive HTTP/1.1 200 OK Content-Language: en Cache-control: no-cache, must-revalidate Fitbit-Rate-Limit-Limit: 150 Expires: Thu, 01 Jan 1970 00:00:00 GMT X-UA-Compatible: IE=edge,chrome=1 Set-Cookie: __cfduid=d71a2f576c1c54957e6f80d06e96669ed1447440942; expires=Sat, 12-Nov-16 18:55:42 GMT; path=/; domain=.fitbit.com; HttpOnly Set-Cookie: JSESSIONID=5E09F1546D320DE38D6135832F0FEEE4.fitbit1; Path=/; HttpOnly Connection: keep-alive Server: cloudflare-nginx Pragma: no-cache X-Frame-Options: SAMEORIGIN Vary: Accept-Encoding Date: Fri, 13 Nov 2015 18:55:42 GMT Transfer-Encoding: chunked Fitbit-Rate-Limit-Remaining: 148 CF-RAY: 244cb140f3c623d2-IAD Fitbit-Rate-Limit-Reset: 258 Content-Type: application/json;charset=UTF-8 { "activities-steps": [ { "dateTime": "2015-10-14", "value": "0" }, { "dateTime": "2015-10-15", "value": "0" }, { "dateTime": "2015-10-16", "value": "0" }, { "dateTime": "2015-10-17", "value": "0" }, { "dateTime": "2015-10-18", "value": "0" }, { "dateTime": "2015-10-19", "value": "0" }, { "dateTime": "2015-10-20", "value": "0" }, { "dateTime": "2015-10-21", "value": "0" }, { "dateTime": "2015-10-22", "value": "131" }, { "dateTime": "2015-10-23", "value": "0" }, { "dateTime": "2015-10-24", "value": "0" }, { "dateTime": "2015-10-25", "value": "0" }, { "dateTime": "2015-10-26", "value": "0" }, { "dateTime": "2015-10-27", "value": "0" }, { "dateTime": "2015-10-28", "value": "0" }, { "dateTime": "2015-10-29", "value": "0" }, { "dateTime": "2015-10-30", "value": "0" }, { "dateTime": "2015-10-31", "value": "0" }, { "dateTime": "2015-11-01", "value": "0" }, { "dateTime": "2015-11-02", "value": "0" }, { "dateTime": "2015-11-03", "value": "0" }, { "dateTime": "2015-11-04", "value": "0" }, { "dateTime": "2015-11-05", "value": "0" }, { "dateTime": "2015-11-06", "value": "0" }, { "dateTime": "2015-11-07", "value": "0" }, { "dateTime": "2015-11-08", "value": "0" }, { "dateTime": "2015-11-09", "value": "0" }, { "dateTime": "2015-11-10", "value": "0" }, { "dateTime": "2015-11-11", "value": "0" }, { "dateTime": "2015-11-12", "value": "0" }, { "dateTime": "2015-11-13", "value": "0" } ] }