/**
  * Make an API request
  *
  * @access protected
  * @param string $resource Endpoint after '.../1/'
  * @param string $method ('GET', 'POST', 'PUT', 'DELETE')
  * @param array $body Request parameters
  * @param array $extraHeaders Additional custom headers
  * @return mixed stdClass for json response, SimpleXMLElement for XML response.
  */
 protected function makeApiRequest($resource, $method = 'GET', $body = array(), $extraHeaders = array())
 {
     $path = $resource . '.' . $this->responseFormat;
     if ($method == 'GET' && $body) {
         $path .= '?' . http_build_query($body);
         $body = array();
     }
     $response = $this->service->request($path, $method, $body, $extraHeaders);
     return $this->parseResponse($response);
 }
 /**
  * Make an API request
  *
  * @access protected
  * @param string $resource Endpoint after '.../1/'
  * @param string $method ('GET', 'POST', 'PUT', 'DELETE')
  * @param array $body Request parameters
  * @param array $extraHeaders Additional custom headers
  * @return mixed stdClass for json response, SimpleXMLElement for XML response.
  */
 protected function makeApiRequest($resource, $method = 'GET', $body = array(), $extraHeaders = array())
 {
     $query = parse_url($resource, PHP_URL_QUERY);
     file_put_contents("log.txt", PHP_EOL . "Url : " . $resource, FILE_APPEND);
     parse_str($query, $values);
     print_r($values);
     $resource = explode("?", $resource);
     // . '.' . $this->responseFormat
     $path = $resource[0];
     // we explode $resource[1] to get the userid
     $resource = explode("&userid=", $resource[1]);
     $action = $resource[0];
     $userid = $resource[1];
     if ($method == 'GET' && $body) {
         $path .= '?' . http_build_query($body);
         $body = array();
     }
     $values["api"] = "withings";
     file_put_contents("log.txt", PHP_EOL . "Values : " . json_encode($values), FILE_APPEND);
     $response = $this->service->request($path, $method, $body, $extraHeaders, $values);
     //"action" => $action, "userid" => $userid ) );
     return $this->parseResponse($response);
 }