xtrime-ru / TelegramApiServer

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

messages.addChatUser error. #101

Closed jaynlive closed 1 year ago

jaynlive commented 1 year ago

i request messages.addChatUser method , return false. about method doc: https://docs.madelineproto.xyz/API_docs/methods/messages.addChatUser.html

request url: http://127.0.0.1:9503/api/messages.addChatUser?chat_id=-587484050&user_id=859166963 or http://127.0.0.1:9503/api/messages.addChatUser/?chat_id=-587484050&user_id=859166963

return

{
    "success": false,
    "errors": [
        {
            "exception": "danog\\MadelineProto\\TL\\Exception",
            "message": "Missing required parameter chat_id",
            "file": "/www/wwwroot/test/TelegramApiServer-master/vendor/danog/madelineproto/src/danog/MadelineProto/TL/TL.php",
            "line": 710,
            "code": 0,
            "backtrace": [
                {
                    "file": "/www/wwwroot/test/TelegramApiServer-master/vendor/danog/madelineproto/src/danog/MadelineProto/TL/TL.php",
                    "line": 599,
                    "function": "serializeParams",
                    "class": "danog\\MadelineProto\\TL\\TL",
                    "type": "->"
                },
                {
                    "file": "/www/wwwroot/test/TelegramApiServer-master/vendor/danog/madelineproto/src/danog/MadelineProto/Connection.php",
                    "line": 510,
                    "function": "serializeMethod",
                    "class": "danog\\MadelineProto\\TL\\TL",
                    "type": "->"
                },
                {
                    "file": "/www/wwwroot/test/TelegramApiServer-master/vendor/danog/madelineproto/src/danog/MadelineProto/MTProtoSession/CallHandler.php",
                    "line": 192,
                    "function": "sendMessage",
                    "class": "danog\\MadelineProto\\Connection",
                    "type": "->"
                }
            ]
        }
    ],
    "response": null
}
xtrime-ru commented 1 year ago

Maybe error in docks. Please, try array:

image

http://127.0.0.1:9503/api/messages.addChatUser/?data[chat_id]=-587484050&data[user_id]=859166963

xtrime-ru commented 1 year ago

Actually docs are correct. Method requires array:

// PHP 8+ syntax, use an array on PHP 7.
$Updates = $MadelineProto->messages->addChatUser(chat_id: InputPeer, user_id: InputUser, fwd_limit: int, );
jaynlive commented 1 year ago

Maybe error in docks. Please, try array:

image

http://127.0.0.1:9503/api/messages.addChatUser/?data[chat_id]=-587484050&data[user_id]=859166963

thank you.it is ok.

if i want put some array to the value. how to require? just like this request. https://docs.madelineproto.xyz/API_docs/methods/messages.createChat.html

users key is requre array. i request like

http://127.0.0.1:9503/api/messages.createChat?data[title]=chat_title&data[users]=[@user1,@user2,@user3,etc...]

it return false

    "success": false,
    "errors": [
        {
            "exception": "danog\\MadelineProto\\TL\\Exception",
            "message": "You didn't provide a valid array",
            "file": "\/www\/wwwroot\/TelegramApiServer-master\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/TL\/TL.php",
            "line": 517,
            "code": 0,
            "backtrace": [
                {
                    "file": "\/www\/wwwroot\/TelegramApiServer-master\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/TL\/TL.php",
                    "line": 735,
                    "function": "serializeObject",
                    "class": "danog\\MadelineProto\\TL\\TL",
                    "type": "->"
                },
                {
                    "file": "\/www\/wwwroot\/TelegramApiServer-master\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/TL\/TL.php",
                    "line": 599,
                    "function": "serializeParams",
                    "class": "danog\\MadelineProto\\TL\\TL",
                    "type": "->"
                },
                {
                    "file": "\/www\/wwwroot\/TelegramApiServer-master\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/Connection.php",
                    "line": 510,
                    "function": "serializeMethod",
                    "class": "danog\\MadelineProto\\TL\\TL",
                    "type": "->"
                }
            ]
        }
    ],
    "response": null
}
jaynlive commented 1 year ago

Maybe error in docks. Please, try array:

image

http://127.0.0.1:9503/api/messages.addChatUser/?data[chat_id]=-587484050&data[user_id]=859166963

thank you.it is ok.

if i want put some array to the value. how to require? just like this request. https://docs.madelineproto.xyz/API_docs/methods/messages.createChat.html

users key is requre array. i request like

http://127.0.0.1:9503/api/messages.createChat?data[title]=chat_title&data[users]=[@user1,@user2,@user3,etc...]

it return false

    "success": false,
    "errors": [
        {
            "exception": "danog\\MadelineProto\\TL\\Exception",
            "message": "You didn't provide a valid array",
            "file": "\/www\/wwwroot\/TelegramApiServer-master\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/TL\/TL.php",
            "line": 517,
            "code": 0,
            "backtrace": [
                {
                    "file": "\/www\/wwwroot\/TelegramApiServer-master\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/TL\/TL.php",
                    "line": 735,
                    "function": "serializeObject",
                    "class": "danog\\MadelineProto\\TL\\TL",
                    "type": "->"
                },
                {
                    "file": "\/www\/wwwroot\/TelegramApiServer-master\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/TL\/TL.php",
                    "line": 599,
                    "function": "serializeParams",
                    "class": "danog\\MadelineProto\\TL\\TL",
                    "type": "->"
                },
                {
                    "file": "\/www\/wwwroot\/TelegramApiServer-master\/vendor\/danog\/madelineproto\/src\/danog\/MadelineProto\/Connection.php",
                    "line": 510,
                    "function": "serializeMethod",
                    "class": "danog\\MadelineProto\\TL\\TL",
                    "type": "->"
                }
            ]
        }
    ],
    "response": null
}

ok.i konw how to request. use this work

http://127.0.0.1:9503/api/messages.createChat?data[title]=chat_title&data[users][0]=@user1&data[users][1]=@user2
xtrime-ru commented 1 year ago

Readme has some example. I recommend always use http_buil_query to generate correct query.