Commit f0f5e52c authored by MBoretto's avatar MBoretto

$input_raw Removed

parent a051f40f
...@@ -17,8 +17,6 @@ class Request ...@@ -17,8 +17,6 @@ class Request
{ {
private static $telegram; private static $telegram;
private static $input; private static $input;
private static $input_raw;
private static $server_response;
private static $methods = array( private static $methods = array(
'getMe', 'getMe',
...@@ -46,10 +44,10 @@ class Request ...@@ -46,10 +44,10 @@ class Request
} }
} }
public static function setInputRaw($input_raw) public static function setInputRaw($input)
{ {
if (is_string($input_raw)) { if (is_string($input)) {
self::$input_raw = $input_raw; self::$input = $input;
} else { } else {
throw new TelegramException("Log input is not a string"); throw new TelegramException("Log input is not a string");
} }
...@@ -63,7 +61,7 @@ class Request ...@@ -63,7 +61,7 @@ class Request
self::setInputRaw(file_get_contents('php://input')); self::setInputRaw(file_get_contents('php://input'));
} }
self::log(); self::log();
return self::$input_raw; return self::$input;
} }
...@@ -77,7 +75,7 @@ class Request ...@@ -77,7 +75,7 @@ class Request
return false; return false;
} }
$status = file_put_contents($path, self::$input_raw . "\n", FILE_APPEND); $status = file_put_contents($path, self::$input . "\n", FILE_APPEND);
return $status; return $status;
} }
...@@ -109,12 +107,12 @@ class Request ...@@ -109,12 +107,12 @@ class Request
return $fake_response; return $fake_response;
} }
public static function executeCurl(i$action, array $data) public static function executeCurl($action, array $data)
{ {
$ch = curl_init(); $ch = curl_init();
if ($ch === false) { if ($ch === false) {
throw new TelegramException('Curl Failed to initialize'); throw new TelegramException('Curl failed to initialize');
} }
$curlConfig = array( $curlConfig = array(
...@@ -136,6 +134,11 @@ class Request ...@@ -136,6 +134,11 @@ class Request
if ($result === false) { if ($result === false) {
throw new TelegramException(curl_error($ch), curl_errno($ch)); throw new TelegramException(curl_error($ch), curl_errno($ch));
} }
if (empty($result)) {
throw new TelegramException('Empty server response');
}
curl_close($ch); curl_close($ch);
return $result; return $result;
} }
...@@ -153,15 +156,6 @@ class Request ...@@ -153,15 +156,6 @@ class Request
$result = self::executeCurl($action, $data); $result = self::executeCurl($action, $data);
if (empty($result)) {
$response['ok'] = 1;
$response['error_code'] = 1;
$response['description'] = 'Empty server response';
$result =json_encode($response);
}
//For the getUpdate method log
//self::setInputRaw($result);
$bot_name = self::$telegram->getBotName(); $bot_name = self::$telegram->getBotName();
return new ServerResponse(json_decode($result, true), $bot_name); return new ServerResponse(json_decode($result, true), $bot_name);
} }
...@@ -193,7 +187,6 @@ class Request ...@@ -193,7 +187,6 @@ class Request
//sendVoice //sendVoice
public static function sendLocation(array $data) public static function sendLocation(array $data)
{ {
if (empty($data)) { if (empty($data)) {
throw new TelegramException('Data is empty!'); throw new TelegramException('Data is empty!');
} }
...@@ -221,15 +214,8 @@ class Request ...@@ -221,15 +214,8 @@ class Request
if ($update = self::$telegram->getCustomUpdate()) { if ($update = self::$telegram->getCustomUpdate()) {
self::setInputRaw($update); self::setInputRaw($update);
} else { } else {
$result = self::executeCurl('getUpdates', $data); $result = self::executeCurl('getUpdates', $data);
if (empty($result)) {
$response['ok'] = 1;
$response['error_code'] = 1;
$response['description'] = 'Empty server response';
$result =json_encode($response);
}
self::setInputRaw($result); self::setInputRaw($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