private function SendinblueHttpClient::doRequest in SendinBlue 7.2
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 SendinblueHttpClient::doRequest()
- SendinblueHttpClient::delete in includes/
Http/ SendinblueHttpClient.php - Delete Request of API.
- SendinblueHttpClient::get in includes/
Http/ SendinblueHttpClient.php - Get Request of API.
- SendinblueHttpClient::post in includes/
Http/ SendinblueHttpClient.php - Post Request of API.
- SendinblueHttpClient::put in includes/
Http/ SendinblueHttpClient.php - Put Request of API.
File
- includes/
Http/ SendinblueHttpClient.php, line 84
Class
- SendinblueHttpClient
- 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);
}