. * * @package LibreNMS * @link http://librenms.org * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ namespace LibreNMS\Alert\Transport; use LibreNMS\Interfaces\Alert\Transport; class Telegram implements Transport { public function deliverAlert($obj, $opts) { foreach ($opts as $chat_id => $data) { $curl = curl_init(); set_curl_proxy($curl); $text = urlencode($obj['msg']); print_r($data); curl_setopt($curl, CURLOPT_URL, ("https://api.telegram.org/bot{$data['token']}/sendMessage?chat_id={$data['chat_id']}&text=$text")); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($code != 200) { var_dump("API '$host' returned Error"); //FIXME: propper debuging var_dump("Params: " . $api); //FIXME: propper debuging var_dump("Return: " . $ret); //FIXME: propper debuging return 'HTTP Status code ' . $code; } } return true; } }