/**
  * Executes the api request.
  * 
  * @return string the xml response
  *
  * @throws \Google\Spreadsheet\Exception If the was a problem with the request.
  *                                       Will throw an exception if the response
  *                                       code is 300 or greater
  */
 public function execute()
 {
     $curlParams = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => 0, CURLOPT_FAILONERROR => false, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_VERBOSE => false);
     $ch = curl_init();
     curl_setopt_array($ch, $curlParams);
     curl_setopt($ch, CURLOPT_URL, $this->request->getUrl());
     if ($this->request->getMethod() === 'POST' || $this->request->getMethod() === 'PUT') {
         curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request->getPost());
     }
     $headers = array();
     if (count($this->request->getHeaders()) > 0) {
         foreach ($this->request->getHeaders() as $k => $v) {
             $headers[] = "{$k}: {$v}";
         }
     }
     $headers[] = "Authorization: OAuth " . $this->request->getAccessToken();
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod());
     curl_setopt($ch, CURLOPT_USERAGENT, $this->request->getUserAgent());
     $ret = curl_exec($ch);
     $info = curl_getinfo($ch);
     if ((int) $info['http_code'] > 299) {
         $exception = new Exception('Error in Google Request: ' . $ret, $info['http_code']);
         $exception->setRequest($this->request);
         $this->resetRequestParams();
         throw $exception;
     }
     $this->resetRequestParams();
     return $ret;
 }