示例#1
-1
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $username = $input->getOption('username');
     $password = $input->getOption('password');
     $date = $input->getOption('date');
     if (is_null($username) || is_null($password)) {
         throw new \InvalidArgumentException('Both username and password are required.');
     }
     // Make request to get the access_token
     $body = array("username" => $username, "password" => $password);
     $response = Unirest\Request::post("https://app.mybasis.com/login", "", $body);
     $response_cookie = $response->headers['Set-Cookie'][0];
     $cookieArray = explode(';', $response_cookie);
     $accessToken = explode('=', $cookieArray[0])[1];
     // Make request to get the data
     $metricURL = 'https://app.mybasis.com/api/v1/metricsday/me?day=' . $date . '&padding=0' . '&heartrate=true' . '&steps=true' . '&calories=true' . '&gsr=true' . '&skin_temp=true' . '&air_temp=true';
     $headers = array("Accept" => "application/json");
     Unirest\Request::cookie("access_token=" . $accessToken);
     $response = Unirest\Request::get($metricURL, $headers, $body);
     print_r($response->raw_body);
     //        print_r($response->code);        // HTTP Status code
     //        print_r($response->headers);     // Headers
     //        print_r($response->body);        // Parsed body
     //        print_r($response->raw_body);    // Unparsed body
     //
     //
     //        echo $metricURL;
 }