PHP Classes

How to Use Saved Token To Submit Fitbit API Call

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  How to Use Saved Token To Submit...  >  (Un) Subscribe thread alerts  
Subject:How to Use Saved Token To Submit...
Summary:I would love an example of how to use a saved token
Messages:16
Author:Colin Urban
Date:2015-03-19 21:17:12
 
  1 - 10   11 - 16  

  11. Re: How to Use Saved Token To Submit...   Reply   Report abuse  
Picture of Colin Urban Colin Urban - 2015-03-30 13:59:00 - In reply to message 11 from Manuel Lemos
This seems to be working properly. After the Authorization page, I see the key and secret in the $_SESSION variable. The token still doesn't seem authorized, it's never added to the client object and doesn't seem to work for API calls.

Any other thoughts? Thanks again, I know this must be a special circumstance, the library was easy and flawless in my last project.

  12. Re: How to Use Saved Token To Submit...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-03-30 18:55:41 - In reply to message 12 from Colin Urban
When the user is redirected back your return page the session variable continues to not be set because the class will perform an extra step to validate the the authorization. That happens inside the Process call.

If it does not happen, the log messages explain why.

That is why I asked you to show me the contents of the $_SESSION variables in the beginning of the script because I suspect your sessions are not being recorded.

If all else fails, what we can do is to contact each other via Skype or some other program that allows screen sharing so we can nail the problem. If you would like that, add my Skype account manuellemos.

  13. Re: How to Use Saved Token To Submit...   Reply   Report abuse  
Picture of Tash Solangi Tash Solangi - 2015-08-31 00:39:02 - In reply to message 13 from Manuel Lemos
I would like to do the same... I would like to store the user information and allow the users to login to my site to then be able to link the data with fitbit... also, I would like to run a script to download everyone's data to update their information. It is for a competition we are doing with a leaderboard... so would like to pull everyone's fitbit data and update the map/graphs

please help!

  14. Re: How to Use Saved Token To Submit...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-08-31 01:55:35 - In reply to message 14 from Tash Solangi
Just try the login_with_fitbit.php or login_with_fitbit2.php scripts and let me know if you have any difficulties.

  15. Re: How to Use Saved Token To Submit...   Reply   Report abuse  
Picture of Tash Solangi Tash Solangi - 2015-08-31 04:07:05 - In reply to message 15 from Manuel Lemos
I am able to connect and get data from fitbit, and store it in mysql... what I am looking to do is store the credentials so the user does not have to resign into fitbit to have their data updated. I want to have it where all they will need to do is be logged into my site and data willy by sync'd or i can run a script to update everyone who has registered...

I don't see what credentials/tokens I need to save and how do I feed them back...

  16. Re: How to Use Saved Token To Submit...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-08-31 19:54:01 - In reply to message 16 from Tash Solangi
By default the OAuth class stores tokens in session variables.

If you want to access the API on behalf of the user when the user is not present, sessions are not the right solution because sessions only exists when the user accesses your Web site.

What you can do is to use a sub-class that stores OAuth tokens in a MySQL database using the mysqli extension.

There is an example script for using this sub-class with Google. You just need to make a few adjustments to make it work with Fitbit:

phpclasses.org/package/7700-PHP-Aut ...

Then there is a script that actually accesses the API when the user is not present using tokens stored in a database:

phpclasses.org/package/7700-PHP-Aut ...

You should also read this tutorial article that explains how it works.

phpclasses.org/blog/package/7700/po ...

 
  1 - 10   11 - 16