xtrime-ru / TelegramApiServer

Fast, simple, async php telegram api server: MadelineProto + Amp HTTP Server
https://tg.i-c-a.su
MIT License
576 stars 130 forks source link

handling exceptions ? #33

Closed artin closed 4 years ago

artin commented 4 years ago

How do you handle exceptions ?

for example an invalid channel

url = 'http://127.0.0.1:9503/api/get_full_info/?data=@breakingmash11111111111111111111111111'

response : failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request

server.php output : [2020-05-22 07:31:46] [error] Username resolution failed with error USERNAME_INVALID [2020-05-22 07:31:46] [error] USERNAME_INVALID { "exception": "danog\MadelineProto\RPCErrorException", "message": "USERNAME_INVALID", "file": "\/home\/test\/TelegramApiServer\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/MTProtoSession\/ResponseHandler.php", "line": 462, "code": 400 }

artin commented 4 years ago

I was using file_get_contents ... Using Curl solved the problem and I can see the exception :)