Zn4rK / php-withings

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

Activities - Date not sent #3

Closed RomainGoncalves closed 10 years ago

RomainGoncalves commented 10 years ago

Hi again,

I'm trying to get Activities now. Like steps on a specific date. The date params needs to be present, I've added it, also modified the file Api.php to add the date to the request, but it still doesn't add it to the request. It sends a request to the API properly, while forgetting to input the data parameter.

Here's the modification I made to Activity.php (otherwise I was getting thrown exceptions coz the date was missing)


public function getActivity(array $params=array()) {
        if(empty($params) || !isset($params['date'])) {
            throw new ApiException('Parameter "date" can\'t be empty');
        }

        // Activity... I don't have any withingsproducts that have
        // activites so this is untested...
        $activity = $this->request('v2/measure', 'getactivity');
        $activity += $params; // That add the data to the request params, as it wasn't sent to the collection before

        return new Collection\Activity($activity);
    }
Zn4rK commented 10 years ago

Make a pull request and I'll accept it. Otherwise I'll take your fix and apply it later when I've got the time.

I must have missed that the Withings API has the date as a required param. Their documentation is not perfect, but I can see that you are absolutley right. http://www.withings.com/api#activitymetrics

RomainGoncalves commented 10 years ago

Hold on, it's still not right, I'm still on it. Once I get it down I'll make a pull request

RomainGoncalves commented 10 years ago

Done