Please replace {channel}
, {token}
and data
argument.
function bugify($channel, $data = '')
{
$token = '{token}';
$curl = curl_init();
curl_setopt_array(
$curl,
array(
CURLOPT_URL => 'https://push.bugify.io/' . $channel,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
'Content-Type: text/plain',
'Authorization: Bearer ' . $token
),
)
);
$response = curl_exec($curl);
if ($response === false) {
// push.bugify.io could not be reached
return ['error' => curl_errno($curl), 'info' => curl_error($curl)];
}
$status = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status === 200) {
return true;
}
// push.bugify.io returned an error
return json_decode($response, true);
}
if (($response = bugify('{channel}', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')) !== true) {
print_r($response);
}