Zn4rK / php-withings

PSR-FIG Compatible Withings Body metrics Services API written in PHP.
17 stars 14 forks source link

getActivites() not working #24

Closed Sonemai closed 7 years ago

Sonemai commented 7 years ago

I can't get getActivites working. It's not returning any values the same way getMeasures() is. I've tried to recreate the foreach loop used in the example. $config is the same used for measures (example). $api = new WithingsApi($config); $Auser = $api->getUser();

foreach($Auser->getActivites() as $activites) { echo $activites->getCreatedAt() . ':
';

echo 'Steps: ' . $activites->getSteps() . ' steps';
echo '<hr>';

}

Zn4rK commented 7 years ago

Since Withings latest Android update I can't get their app to work (so I can't add any activities). Do you get any data from the request at all?

print_r($activity) on this line to check: https://github.com/Zn4rK/php-withings/blob/master/src/Paxx/Withings/Api.php#L178

Sonemai commented 7 years ago

Hey. Thank you for your reply. I tested printing the $activity. Indeed it returned activities in array and in json. Still don't quite understand why getActivites isn't returning the same info. I managed to get getActivity() to print an empty json like: [{},{},{},{},{},{},{},{},{},{},{}]

Sonemai commented 7 years ago

Wait a second... now I managed to get the filled json without the print_r. (Exactly same code as before). Some dark magic going on.

Zn4rK commented 7 years ago

I think it's an issue with Withings. I don't really know why you are getting inconsistent results. Try breaking it down a bit more, and see if you get any data from Withings with the API.