02-03-2016 03:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-03-2016 03:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm working on an application that aggregate data from a group of user.
I've already done the authorization for the users and the subcription of each user to the subscriber of my app.
The subscriber works fine, in fact i receive the update notification everytime a user sync his data.
My question is:
How i have to do to make request to the API to get the new activity with the only X-Fitbit-Signature that i receive in update notification header ?
I'm working on wordpress, so PHP
Thanks
Answered! Go to the Best Answer.
Accepted Solutions
02-03-2016 10:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-03-2016 10:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
The subscriptions notification is a POST request to your subscriber. Look at the JSON in the request body and you'll see the user id, the name of the subscription, the date, and the resource collection that changed. In your app, lookup the OAuth 2 access token for that user id and make API requests as you normally do.
The X-Fitbit-Signature header is what allows your subscriber to know the request is authentic from Fitbit.
02-03-2016 10:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-03-2016 10:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
The subscriptions notification is a POST request to your subscriber. Look at the JSON in the request body and you'll see the user id, the name of the subscription, the date, and the resource collection that changed. In your app, lookup the OAuth 2 access token for that user id and make API requests as you normally do.
The X-Fitbit-Signature header is what allows your subscriber to know the request is authentic from Fitbit.
02-04-2016 03:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-04-2016 03:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks Jeremiah, i wasn't sure that I have to collect the auth token of the all the users.
I tried with cocoa rest client to call the API url build with the parameters received and the user acces token and works fine.
In php i'm trying via cURL but i receive only 1 fro response and not the json.
Here it is my code:
$headr = array(); $headr[] = 'Authorization: Bearer '.$accesstoken;
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $APIurl); curl_setopt($crl, CURLOPT_HTTPHEADER,$headr); curl_setopt($crl, CURLOPT_POST,false); $rest = curl_exec($crl); if ($rest === false) { // throw new Exception('Curl error: ' . curl_error($crl)); $rest = 'Curl error: ' . curl_error($crl); }

02-04-2016 03:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-04-2016 03:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Nevermind, I already resolved.
I had to add this line to have response body
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
Thanks for helping me !

02-24-2016 03:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-24-2016 03:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@JeremiahFitbit How do I make a call to the API in order to fetch the user's activity changes with only X-Fitbit_signature that i received in header. I am trying to automate the process so that anytime any notification comes i can fetch the user activity data. I am using oauth 2.0 and i cannot create access token for fitbit as it needs to have a authorization code which comes after redirection from the fitbit. Kindly help. I have asked at Twitter support, emailed and looked at many places but i can not find a solution. This is very important. Kindly help.

