@@ -60,12 +60,12 @@ public static function getInput()
60
60
} else {
61
61
self ::setInputRaw (file_get_contents ('php://input ' ));
62
62
}
63
- self ::log ();
63
+ self ::log (self :: $ input );
64
64
return self ::$ input ;
65
65
}
66
66
67
67
68
- private static function log ()
68
+ private static function log ($ string )
69
69
{
70
70
if (!self ::$ telegram ->getLogRequests ()) {
71
71
return false ;
@@ -75,8 +75,8 @@ private static function log()
75
75
return false ;
76
76
}
77
77
78
- $ status = file_put_contents ($ path , self ::$ input . "\n" , FILE_APPEND );
79
-
78
+ // $status = file_put_contents($path, self::$input . "\n", FILE_APPEND);
79
+ $ status = file_put_contents ( $ path , $ string . "\n" , FILE_APPEND );
80
80
return $ status ;
81
81
}
82
82
@@ -128,13 +128,36 @@ public static function executeCurl($action, array $data)
128
128
$ curlConfig [CURLOPT_POSTFIELDS ] = $ data ;
129
129
}
130
130
131
+ if ( self ::$ telegram ->getLogVerbosity () >= 3 ) {
132
+ $ curlConfig [CURLOPT_VERBOSE ] = true ;
133
+ $ verbose = fopen ('php://temp ' , 'w+ ' );
134
+ curl_setopt ($ ch , CURLOPT_STDERR , $ verbose );
135
+ //Not so useful
136
+ //$info = curl_getinfo($ch);
137
+ //echo "Info\n";
138
+ //print_r($info);
139
+ }
140
+
131
141
curl_setopt_array ($ ch , $ curlConfig );
132
142
$ result = curl_exec ($ ch );
133
143
144
+ //Logging curl requests
145
+ if ( self ::$ telegram ->getLogVerbosity () >= 3 ) {
146
+ rewind ($ verbose );
147
+ $ verboseLog = stream_get_contents ($ verbose );
148
+ self ::log ("Verbose curl output: \n" . htmlspecialchars ($ verboseLog ). "\n" );
149
+ }
150
+
151
+ //Logging getUpdates Updates
152
+ //Logging curl updates
153
+ if ($ action == 'getUpdates ' & self ::$ telegram ->getLogVerbosity () >= 1 | self ::$ telegram ->getLogVerbosity () >= 3 ) {
154
+ self ::setInputRaw ($ result );
155
+ self ::log ($ result );
156
+ }
157
+
134
158
if ($ result === false ) {
135
159
throw new TelegramException (curl_error ($ ch ), curl_errno ($ ch ));
136
160
}
137
-
138
161
if (empty ($ result )) {
139
162
throw new TelegramException ('Empty server response ' );
140
163
}
@@ -162,7 +185,6 @@ public static function send($action, array $data = null)
162
185
163
186
public static function getMe ()
164
187
{
165
-
166
188
$ result = self ::send ('getMe ' );
167
189
return $ result ;
168
190
}
@@ -197,7 +219,6 @@ public static function sendLocation(array $data)
197
219
198
220
public static function sendChatAction (array $ data )
199
221
{
200
-
201
222
if (empty ($ data )) {
202
223
throw new TelegramException ('Data is empty! ' );
203
224
}
@@ -210,21 +231,8 @@ public static function sendChatAction(array $data)
210
231
211
232
public static function getUpdates ($ data )
212
233
{
213
-
214
- if ($ update = self ::$ telegram ->getCustomUpdate ()) {
215
- self ::setInputRaw ($ update );
216
- } else {
217
- $ result = self ::executeCurl ('getUpdates ' , $ data );
218
-
219
- self ::setInputRaw ($ result );
220
-
221
- }
222
-
223
- self ::log ();
224
-
225
- $ bot_name = self ::$ telegram ->getBotName ();
226
- return new ServerResponse (json_decode ($ result , true ), $ bot_name );
227
-
234
+ $ result = self ::send ('getUpdates ' , $ data );
235
+ return $ result ;
228
236
}
229
237
230
238
public static function setWebhook ($ url )
0 commit comments