adambuczek
9/21/2016 - 9:16 AM

hipchat-integration-php-curl.php

  function hipchatReport($message) {

    $ch = curl_init();

    $data_string = json_encode(array(
      "color" => "red",
      "notify" => "true",
      "message_format" => "text",
      "from" => CONFIG['HIPCHAT_FROM_NAME'],
      "message" => $message
    ));

    $opts = array(
      CURLOPT_URL => CONFIG['HIPCHAT_INTEG_URL'],
      CURLOPT_POST => true,
      CURLOPT_POSTFIELDS => $data_string,
      CURLOPT_HEADER => true,
      CURLOPT_HTTPHEADER => array(
          'Content-Type: application/json',
          'Content-Length: ' . strlen($data_string)
      ),
      CURLOPT_RETURNTRANSFER => true // don't echo the response so we can silently ignore it
    );

    curl_setopt_array($ch, $opts);
    curl_exec($ch);

  }