Commit f2277485 authored by MBoretto's avatar MBoretto

Add exception to Curl

parent 6d35657a
......@@ -120,7 +120,12 @@ class Request
return new ServerResponse($fake_response, self::$telegram->getBotName());
}
$ch = curl_init();
if ($ch === FALSE) {
throw new TelegramException('Curl Failed to initialize');
}
$curlConfig = array(
CURLOPT_URL => 'https://api.telegram.org/bot' . self::$telegram->getApiKey() . '/' . $action,
CURLOPT_POST => true,
......@@ -136,6 +141,10 @@ class Request
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
if ($result === FALSE) {
throw new TelegramException(curl_error($ch), curl_errno($ch));
}
curl_close($ch);
if (empty($result)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment