xtrime-ru / TelegramApiServer

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

Convert bot file_id to madeline object #133

Closed foremtehan closed 1 year ago

foremtehan commented 1 year ago

I want to convert the file from tdlib to madeline object i used:

curl --location --request POST 'http://127.0.0.1:9503/api/MTProtoToBotAPI' --header 'Content-Type: application/json' --data-raw '{
    "data":{
        "document": {
            "file_name": "oks.mp4",
            "mime_type": "application/octet-stream",
            "file_id": "BQACAgQAAxkDAAILiWSyl4uXmb9rnrUcOjxmo-7kEXRVAAKqDgACS76RUZYP-QAB7E6fLi8E",
            "file_unique_id": "AgADqg4AAku-kVE",
            "file_size": 104857600
        }
    }
}'

But i got error:

danog\\MadelineProto\\MTProto::MTProtoToBotAPI(): Argument #1 ($data) must be of type array, string given, called in /app-host-link/vendor/danog/madelineproto/src/TL/Conversion/BotAPI.php on line 164

i also tried to try: (but got same error)

/api/MTProtoToBotAPI?data["document"]["file_name"]=oks.mp4&data["file_id"]=BQACAgQAAxkDAAILiWSyl4uXmb9rnrUcOjxmo-7kEXRVAAKqDgACS76RUZYP-QAB7E6fLi8E

How can i pass these as array?

xtrime-ru commented 1 year ago

Your document format is wrong.

because you dont have "_" key you trigger this brach and it passes all keys to MTProtoToBotAPI again. And you have strigns in your array.

image