Closed danielberlin closed 8 years ago
I can't reproduce the problem.. it seem related to curl. In 0.17.2 Exceptions are logged this can help to understand the problem.
No exception is logged, the described error above is only visible in the web server's error_log. Should I update curl? What is the minimum required version of curl? Do I need curl for hook mode? I don't think so.
My version of curl is 7.35.0 , curl is used to make all the requests to telegram.
But curl is only used for getUpdate? Since I use hook-example.php, I think it doesn't use curl or does it?
Curl is used for get update, set Web hook and to send any messages to the chat
OK, I think I have to debug my curl which is 7.29.0. Do you have a recommendation where to start from this error on?
Catchable fatal error: Argument 1 passed to Longman\TelegramBot\Entities\ServerResponse::__construct() must be of the type array, null given, called in /myproject/vendor/longman/telegram-bot/src/Request.php on line 151 and defined in /myproject/vendor/longman/telegram-bot/src/Entities/ServerResponse.php on line 26
Try to:
if (empty($result) | is_null($result)) {
Then we will see
phpunit gives:
==== Redirecting to composer installed version in vendor/phpunit ====
PHPUnit 4.1.6-6-g43914fa by Sebastian Bergmann.
Configuration read from /myproject/vendor/longman/telegram-bot/phpunit.xml.dist
.................
Time: 53 ms, Memory: 4.00Mb
OK (17 tests, 68 assertions)
Changing the line still results in
PHP Catchable fatal error: Argument 1 passed to Longman\\TelegramBot\\Entities\\ServerResponse::__construct() must be of the type array, null given, called in /myproject/vendor/longman/telegram-bot/src/Request.php on line 152 and defined in /myproject/vendor/longman/telegram-bot/src/Entities/ServerResponse.php on line 26
BTW, I can monitor outgoing requests such as this to the Telegram server (149.154.167.199) – but still not receiving even a single bot answer in the chat:
Oct 6 12:42:54 host kernel: WWW OUTGOING IN= OUT=eth0 SRC=10.1.2.3 DST=149.154.167.199 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=46695 DF PROTO=TCP SPT=50098 DPT=443 WINDOW=14600 RES=0x00 SYN URGP=0
Help and ideas highly appreciated. Thank you.
What you find inside?
var_dump($result);
Where should I put var_dump($result);
– in Request.php#L141? But then how do I get the output when Telegram is requesting my script? Should I access it from the browser? It should be written to the MySQL (or any other) log...
In hotfix branch I pushed some commits to trace curl errrors (If any) with Exception.
Thanks, downloaded hotfix branch. But where do the Exceptions go?
I don't see them neither in TelegramException.log nor in error_log (still getting Argument 1 passed to Longman\\TelegramBot\\Entities\\ServerResponse::__construct() must be of the type array, null given
).
phpunit in hotfix gives 1) Tests\Unit\ServerResponseTest::testGetUpdatesEmpty Failed asserting that 0 is null.
I've implement a logging system for curl request and response, just set verbosity to 3 as explained in the hotfix readme. Exception are stored in the main dir of the project if are thrown, here.s the name of the file: https://github.com/akalongman/php-telegram-bot/blob/master/src/Exception/TelegramException.php#L19
The logging system now helped to track down the problem to the following logged error (HTTP error before end of send, stop sending
, see below):
{"update_id":12345,
"message":{"message_id":123,"from":{"id":12345,"first_name":"myName","username":"myUserName"},"chat":{"id":12345,"first_name":"myName","username":"myUserName","type":"private"},"date":1445813422,"text":"\/help"}}
Verbose curl output:
* About to connect() to api.telegram.org port 443 (#13)
* Trying 149.154.167.200...
* Connected to api.telegram.org (149.154.167.200) port 443 (#13)
[SSL verbose messages]
> POST /botbot123456:myHash/sendMessage HTTP/1.1
Host: api.telegram.org
Accept: */*
Content-Length: 593
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------6f5ad22da508
< HTTP/1.1 100 Continue
< HTTP/1.1 302 Moved Temporarily
< Server: nginx/1.6.2
< Date: Sun, 25 Oct 2015 23:39:13 GMT
< Content-Type: text/html
< Content-Length: 160
< Connection: keep-alive
< Location: https://core.telegram.org/bots
< Strict-Transport-Security: max-age=31536000; includeSubdomains
* HTTP error before end of send, stop sending
<
* Closing connection 13
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>
The problem is that my API key was entered in a wrong format. Unfortunately, neither api.telegram.org nor php-telegram-bot displayed an error regarding this.
When I set up the bot as described in README.md and call set.php, I get: