Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

A full php code which help me to retrieve data from fitbit

I'm trying to retrieve data from fitbit with my website but facing problems with getting the access token and other staff.
The first page is named test1.php which contains this code:

 

 

<?php

header('Location:https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=XXXXXX&redirect_uri=https%3A%2F%2Fexample.com%2Ftest2.php&scope=activity%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight&expires_in=604800');
exit;

?>

 

 

 

So, from the page "test1.php", I'm redirected to the authorization page of fitbit. There I can select the scope I want to share and then click "Allow". Then I'm redirected to the page www.example.com/test2.php which is my redirect_uri link.
From this stage, I can not do the codes. I have tried several codes but couln't succeed. I need help with this.
I found this in the website. How to do this with PHP? I mean what should I write in my test2.php page to get the access token? And what should I do further to get all data I want?

POST <a href="https://api.fitbit.com/oauth2/token" target="_blank">https://api.fitbit.com/oauth2/token</a>
Authorization: Basic Y2xpZW50X2lkOmNsaWVudCBzZWNyZXQ=
Content-Type: application/x-www-form-urlencoded

client<span class="token italic"><span class="token punctuation">_</span>id=XXXXXX&grant<span class="token punctuation">_</span></span>type=authorization<span class="token italic"><span class="token punctuation">_</span>code&redirect<span class="token punctuation">_</span></span>uri=http%3A%2F%2Fexample.com%2Ffitbit_auth&code=1234567890

 

Best Answer
0 Votes
0 REPLIES 0