You are here

function cc::http_send in Constant Contact 7.3

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

Creates the HTTP request.

@access private

Parameters

string The path of the resource to request eg. /index.php:

string The method to use to make the request eg. GET:

array An array of params to use for this HTTP request, eg. post data:

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 1878
Constant Contact PHP Class

Class

cc
@file Constant Contact PHP Class

Code

function http_send($the_url, $method, $params = array()) {
  $this->http_response = '';
  $this->http_response_code = '';
  $this->http_method = $method;
  $method = drupal_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' && 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);
}