/** * Execute the request and return a response. * * @param array additional cURL options * @return string request response body * @uses Request::check * @uses Arr::get * @uses Remote::get */ public function execute(array $options = NULL) { // Check that all required fields are set $this->check(); // Get the URL of the request $url = $this->url; if (EXTERNAL_API_PROXY) { $options[CURLOPT_PROXYPORT] = EXTERNAL_API_PROXY_PORT; $options[CURLOPT_PROXYTYPE] = 'http'; $options[CURLOPT_PROXY] = EXTERNAL_API_PROXY_URL; } if (!isset($options[CURLOPT_CONNECTTIMEOUT])) { // Use the request default timeout $options[CURLOPT_CONNECTTIMEOUT] = $this->timeout; } if (ENVIRONMENT === 'development') { $options[CURLOPT_SSL_VERIFYPEER] = false; } if ($this->send_header) { // Get the the current headers $headers = isset($options[CURLOPT_HTTPHEADER]) ? $options[CURLOPT_HTTPHEADER] : array(); // Add the Authorization header $headers[] = 'Authorization: ' . $this->as_header(); // Store the new headers $options[CURLOPT_HTTPHEADER] = $headers; } if ($this->method === 'POST') { // Send the request as a POST $options[CURLOPT_POST] = TRUE; if ($post = $this->as_query(NULL, empty($this->upload))) { // Attach the post fields to the request $options[CURLOPT_POSTFIELDS] = $post; } } elseif ($query = $this->as_query()) { // Append the parameters to the query string $url = "{$url}?{$query}"; } return OAuth1::remote($url, $options); }