private function SendinblueMailin::doRequest in SendinBlue 7
Do CURL request with authorization.
Parameters
string $resource: A request action of api.
string $method: A method of curl request.
string $input: A data of curl request.
Return value
array An associate array with respond data.
4 calls to SendinblueMailin::doRequest()
- SendinblueMailin::delete in includes/
sendinblue.mailin.php  - Delete Request of API.
 - SendinblueMailin::get in includes/
sendinblue.mailin.php  - Get Request of API.
 - SendinblueMailin::post in includes/
sendinblue.mailin.php  - Post Request of API.
 - SendinblueMailin::put in includes/
sendinblue.mailin.php  - Put Request of API.
 
File
- includes/
sendinblue.mailin.php, line 46  - Rest class file.
 
Class
- SendinblueMailin
 - Sendinblue REST client.
 
Code
private function doRequest($resource, $method, $input) {
  if (!function_exists('curl_init')) {
    $msg = 'SendinBlue requires CURL module';
    watchdog('sendinblue', $msg, NULL, WATCHDOG_ERROR);
    return NULL;
  }
  $called_url = $this->baseUrl . "/" . $resource;
  $ch = curl_init($called_url);
  $auth_header = 'api-key:' . $this->apiKey;
  $content_header = "Content-Type:application/json";
  //if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  // Windows only over-ride because of our api server.
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  //}
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    $auth_header,
    $content_header,
  ));
  //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
  $data = curl_exec($ch);
  if (curl_errno($ch)) {
    watchdog('sendinblue', 'Curl error: @error', array(
      '@error' => curl_error($ch),
    ), WATCHDOG_ERROR);
  }
  curl_close($ch);
  return drupal_json_decode($data);
}