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

Can we send multiple curl request for refresh token and for steps data at a time

Hi ,

 

I am using fitbit developer api to fetch users steps data for 7 days using curl. For that we have cron job. 

But it takes lots of time to execute (for 85 users).

 

Below is the code am using: 

 

1. First i am requesting api for new accessToken for each user :

$url = 'https://api.fitbit.com/oauth2/token?grant_type=refresh_token&refresh_token='.$refreshToken;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic MjI4NE5OOjU4YzFmYTIzMzg5OTMxZTAzYjUyODFkMzcyMDAwOTQx'));

curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); // return into a variable
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, true);
$result = curl_exec($ch);

 

2.Using new AccessToken again am calling api requesting steps data for each user : 

$url1 = 'https://api.fitbit.com/1/user/'.$accountId.'/activities/tracker/steps/date/'.$currentDate.'/7d.json';
//echo $url1;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer '.$access_token));

curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); // return into a variable
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);

 

Is there any way through which i can call api for refresh token for all users(85) at a same time.

Similarly i want to call api for steps data for all users(85) all at once. Is this possible? Can you provide me proper guidance for the same.

Best Answer
0 Votes
0 REPLIES 0