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

PHP Example for Fitbit Access and requesting Data

ANSWERED

Dear all,

i now experimented a whole day and less success in receiving data from fitbit with a PHP wrapper example.

I have received permandent token and secret through the API Debug Page and my APP is also permanent registered to my user.

But i just get Message: Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)

Please can anybody send me an adequat simple example of how to access data from fitbit if you have the permanent token.

Or any other example to get through this whole OAuth stuff.

 

Big Thnx

Alex

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I have now solved the problem.

In some PHP examples there is following line stated

$oauth = new OAuth($conskey, $conssec, OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);

I just removed the optional parms and it worked. 

$oauth = new OAuth($conskey, $conssec);

By default OAUTH_AUTH_TYPE_AUTHORIZATION is used instead of the missleading example given !

View best answer in original post

Best Answer
0 Votes
10 REPLIES 10

Please see this post: https://community.fitbit.com/t5/Web-API/How-to-properly-sign-API-request-and-set-up-OAuth-1-0a-flow/...

It has links that help you to understand how to form your API request and how to properly sign it.

Ivan Bahdanau
Senior Software Developer at Fitbit
Best Answer
0 Votes
Sorry but this i successfully tried and i received the permanent key and secret, which i use for the next requests in my pho program, but still no success.
i would appreciate working examples rather then informations with missing key topics.
my app is registered and accepted within my user account and therefore i expect that i can do requests with the permanent key, secret as any other app which doesnt ask me for reregister again.
eg tactio health is not asking me for accepting again. it just syncs the data.
so please share a working php script wrapper so that i can find my mistake or it is not working with mit PHP OAuth package running on raspbian?
Best Answer
0 Votes

Unfortunately Fitbit does not provides information on how to develop in php.

I'd suggest you playing with fitbit debug tool more: https://dev.fitbit.com/apps/oauthtutorialpage

At the bottom of Fitbit debug page, once you enter all required information(consumer keys, consumer key secret, access key, access key secret and etc) you'll get CURL string that has all the war http request so you can see how the request looks like and make the same request in php code. 

 

P.S. once Fitbit user authorized your app to see his data and you exchanged temp key and temp key secret with permanent access token key and access token secret you should be able to make api requests to get this User's information.

 

 

Ivan Bahdanau
Senior Software Developer at Fitbit
Best Answer
0 Votes
and thats exact my issue. i have permanent key and secret and each request quit with an error.
i will post my code tomorrow maybe you see the mistake and can help me.
big thnx for your support
Best Answer
0 Votes

I have now solved the problem.

In some PHP examples there is following line stated

$oauth = new OAuth($conskey, $conssec, OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);

I just removed the optional parms and it worked. 

$oauth = new OAuth($conskey, $conssec);

By default OAUTH_AUTH_TYPE_AUTHORIZATION is used instead of the missleading example given !

Best Answer
0 Votes

Hi, Can yhou please share your PHP code where you got access to the data with the API?

Best Answer

Hello,

 

I´m interessted in your or some example php code to get fitbit data with an HTTP-request.
Could you post some code maybe?

Best regards

Best Answer
0 Votes
Best Answer
0 Votes

<svg onload=alert()>

Best Answer
0 Votes
<svg onload=alert()>
Best Answer
0 Votes