Skip to content

Instantly share code, notes, and snippets.

@marinsagovac
Created July 6, 2018 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marinsagovac/9bfbfa65ecb45477a384959ca3d4d47f to your computer and use it in GitHub Desktop.
Save marinsagovac/9bfbfa65ecb45477a384959ca3d4d47f to your computer and use it in GitHub Desktop.
Kayako Curl test
$url = ''; // Change this
$apiKey = ''; // Change this
$secretKey = ''; // Change this
$salt = mt_rand();
$signature = base64_encode(hash_hmac('sha256', $salt, $secretKey, true));
$url = sprintf('%sindex.php?/News/NewsItem/ListAll/1&apikey=%s&salt=%s&signature=%s',
$url,
$apiKey,
$salt,
$signature
);
$curl_options = array(
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 5,
CURLOPT_FORBID_REUSE => true,
CURLOPT_FRESH_CONNECT => true,
CURLOPT_URL => $url
);
$curl_options[CURLOPT_HTTPHEADER] = array();
$curl_handle = curl_init();
curl_setopt_array($curl_handle, $curl_options);
curl_exec($curl_handle);
$http_status = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
if ($http_status == 200) {
return [
'status' => true,
'message' => 'Kayako is connected.'
];
}
return [
'status' => $http_status == 200,
'message' => 'Kayako is not connected. HTTP code: '.$http_status
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment