Skip to content

Commit f0f5e52

Browse files
committed
$input_raw Removed
1 parent a051f40 commit f0f5e52

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

src/Request.php

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class Request
1717
{
1818
private static $telegram;
1919
private static $input;
20-
private static $input_raw;
21-
private static $server_response;
2220

2321
private static $methods = array(
2422
'getMe',
@@ -46,10 +44,10 @@ public static function initialize(Telegram $telegram)
4644
}
4745
}
4846

49-
public static function setInputRaw($input_raw)
47+
public static function setInputRaw($input)
5048
{
51-
if (is_string($input_raw)) {
52-
self::$input_raw = $input_raw;
49+
if (is_string($input)) {
50+
self::$input = $input;
5351
} else {
5452
throw new TelegramException("Log input is not a string");
5553
}
@@ -63,7 +61,7 @@ public static function getInput()
6361
self::setInputRaw(file_get_contents('php://input'));
6462
}
6563
self::log();
66-
return self::$input_raw;
64+
return self::$input;
6765
}
6866

6967

@@ -77,7 +75,7 @@ private static function log()
7775
return false;
7876
}
7977

80-
$status = file_put_contents($path, self::$input_raw . "\n", FILE_APPEND);
78+
$status = file_put_contents($path, self::$input . "\n", FILE_APPEND);
8179

8280
return $status;
8381
}
@@ -109,12 +107,12 @@ public static function generateGeneralFakeServerSesponse($data = null)
109107
return $fake_response;
110108
}
111109

112-
public static function executeCurl(i$action, array $data)
110+
public static function executeCurl($action, array $data)
113111
{
114112

115113
$ch = curl_init();
116114
if ($ch === false) {
117-
throw new TelegramException('Curl Failed to initialize');
115+
throw new TelegramException('Curl failed to initialize');
118116
}
119117

120118
$curlConfig = array(
@@ -136,6 +134,11 @@ public static function executeCurl(i$action, array $data)
136134
if ($result === false) {
137135
throw new TelegramException(curl_error($ch), curl_errno($ch));
138136
}
137+
138+
if (empty($result)) {
139+
throw new TelegramException('Empty server response');
140+
}
141+
139142
curl_close($ch);
140143
return $result;
141144
}
@@ -153,15 +156,6 @@ public static function send($action, array $data = null)
153156

154157
$result = self::executeCurl($action, $data);
155158

156-
if (empty($result)) {
157-
$response['ok'] = 1;
158-
$response['error_code'] = 1;
159-
$response['description'] = 'Empty server response';
160-
$result =json_encode($response);
161-
}
162-
//For the getUpdate method log
163-
//self::setInputRaw($result);
164-
165159
$bot_name = self::$telegram->getBotName();
166160
return new ServerResponse(json_decode($result, true), $bot_name);
167161
}
@@ -193,7 +187,6 @@ public static function sendMessage(array $data)
193187
//sendVoice
194188
public static function sendLocation(array $data)
195189
{
196-
197190
if (empty($data)) {
198191
throw new TelegramException('Data is empty!');
199192
}
@@ -221,15 +214,8 @@ public static function getUpdates($data)
221214
if ($update = self::$telegram->getCustomUpdate()) {
222215
self::setInputRaw($update);
223216
} else {
224-
225217
$result = self::executeCurl('getUpdates', $data);
226218

227-
if (empty($result)) {
228-
$response['ok'] = 1;
229-
$response['error_code'] = 1;
230-
$response['description'] = 'Empty server response';
231-
$result =json_encode($response);
232-
}
233219
self::setInputRaw($result);
234220

235221
}

0 commit comments

Comments
 (0)