You are here

function cc::http_send in Constant Contact 6.3

Same name and namespace in other branches
  1. 6.2 class.cc.php \cc::http_send()
  2. 7.3 class.cc.php \cc::http_send()

* This does most the work of creating the HTTP request * *

Parameters

string The path of the resource to request eg. /index.php: * @param string The method to use to make the request eg. GET * @param array An array of params to use for this HTTP request, eg. post data * * @access private

1 call to cc::http_send()
cc::load_url in ./class.cc.php
* Loads a specific URL, this method is used by the user friendly methods *

File

./class.cc.php, line 1867

Class

cc
@file

Code

function http_send($the_url, $method, $params = array()) {
  $this->http_response = '';
  $this->http_response_code = '';
  $this->http_method = $method;
  $method = strtoupper($method);
  $ch = curl_init($the_url);
  curl_setopt($ch, CURLOPT_USERAGENT, $this->http_user_agent);
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  curl_setopt($ch, CURLOPT_USERPWD, $this->http_user . ':' . $this->http_pass);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-Type: {$this->http_content_type}",
  ));
  curl_setopt($ch, CURLOPT_TIMEOUT, $this->http_request_timeout);
  if ($method == 'POST' or $method == 'PUT' and count($params) > 0) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  }
  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  $this->http_response_body = curl_exec($ch);
  $this->http_response_info = curl_getinfo($ch);
  $this->http_response_error = curl_error($ch);
  $this->http_response_code = $this->http_response_info['http_code'];
  curl_close($ch);
}