Zn4rK / php-withings

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

Added date to request params as per Withings API #4

Closed RomainGoncalves closed 10 years ago

RomainGoncalves commented 10 years ago

Withings' API for Activity requests requires at least one date parameter to be sent.

RomainGoncalves commented 10 years ago

While I was at it I added a support for date range in getActivity.

To use like so:

$user = 'your user data from Withings';
$config = $this->withingsConfig+array(
     'access_token'    => $user->access_token,
    'token_secret'    => $user->secret,
     'user_id'     => $user->withings_id
);

$api = new WithingsApi($config);
$userActivities = $api->getActivity(['startdateymd' => '2013-11-01', 'enddateymd' => '2014-01-09']);

PS: don't do like me and spend 1h trying to work out why Withings doesn't return any values, by making sure your start date is earlier than your end date...