12-16-2014 02:54
12-16-2014 02:54
Hi All,
I am using ohmyauth library for fitbit auth. It is working fine but its giving only one date data and I want to access full data for aunthiticate user.
Below is my code please review and guid me how can I access import all data ?
use ohmy\Auth1;
# start a session to save oauth data in-between redirects
# initialize 3-legged oauth
$fitbit = Auth1::init(3)
->set('key', 'b61dd455b43744248fe109cdf2b8d814')
->set('secret', '1bca137f8f444158958c0403106036c0')
->set('callback', 'https://fitfocus.me/fitbit.php')
# oauth
->request('https://api.fitbit.com/oauth/request_token')
->authorize('https://api.fitbit.com/oauth/authorize')
->access('https://api.fitbit.com/oauth/access_token')
# save user id
->finally(function($data) use(&$user_id) {
$user_id = $data['encoded_user_id'];
});
# destroy session
// ->finally(session_destroy);
# test GET call
$fitbit->GET("https://api.fitbit.com/1/user/$user_id/profile.json")
->then(function($response) {
$_SESSION['profile~'] = json_encode($response->json());
});
$udata = $data = array();
$udata['user_id'] = $data['user_id'] = $user_info['id'];
$udata['api_type'] = $data['api_type'] = 'fitbit';
$udata['profile_data'] = $_SESSION['profile~'];
$udata['created'] = $data['created'] = date('Y-m-d H:i:s');
$fitbit->GET("https://api.fitbit.com/1/user/$user_id/activities/date/2014-03-25.json")
->then(function($response) {
$_SESSION['data~'] = json_encode($response->json());
});
Its giving data of '2014-03-25' and I need all data in user account.
Thanks
Answered! Go to the Best Answer.
12-16-2014 08:27
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
12-16-2014 08:27
Hello,
It gives you data for 2014-03-25 because you query data for that date with query: "https://api.fitbit.com/1/user/$user_id/activities/
You can do all sort of queries to return the data that you want for period of times that you want.
More information you can find here:
https://wiki.fitbit.com/display/API/Fitbit+API
We currently do not allow to import/export all user's data.so you'll have to make several queries to get the data that you want.
Best Answer12-16-2014 08:27
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
12-16-2014 08:27
Hello,
It gives you data for 2014-03-25 because you query data for that date with query: "https://api.fitbit.com/1/user/$user_id/activities/
You can do all sort of queries to return the data that you want for period of times that you want.
More information you can find here:
https://wiki.fitbit.com/display/API/Fitbit+API
We currently do not allow to import/export all user's data.so you'll have to make several queries to get the data that you want.
Best Answer