function new_relic_rpm_curl in New Relic 7
This is the generic cURL function all New Relic Web API calls go through.
Parameters
$url:
array $post:
Return value
bool|string
3 calls to new_relic_rpm_curl()
- new_relic_rpm_reporting in ./
new_relic_rpm.reports.inc - Main page for New Relic reporting. List all the applications on this API Key.
- new_relic_rpm_reporting_details in ./
new_relic_rpm.reports.inc - Load the details for a specific application.
- _new_relic_rpm_deploy in ./
new_relic_rpm.module - Send deployments to New Relic's web API.
File
- ./
new_relic_rpm.module, line 451 - Drupal module implementing New Relic.
Code
function new_relic_rpm_curl($url, $post = array()) {
$api_key = variable_get('new_relic_rpm_api_key', '');
// Set the header with the API key.
$headers[] = "x-api-key: {$api_key}";
// Set up the cURL request.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// There's some notes about Windows not having the CA built-in
if (stripos(PHP_OS, 'WIN') === 0) {
$curl_ssl_verify = FALSE;
}
else {
$curl_ssl_verify = TRUE;
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $curl_ssl_verify);
if (!empty($post)) {
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$return_data = curl_exec($ch);
if (false !== stripos($return_data, 'Access denied')) {
return FALSE;
}
return $return_data;
}