danog / MadelineProto

Async PHP client API for the telegram MTProto protocol
https://docs.madelineproto.xyz
GNU Affero General Public License v3.0
2.83k stars 654 forks source link

getDownloadLink(): Argument #3 ($size) must be of type ?int, string given, called in ... #1410

Closed humpataa closed 1 year ago

humpataa commented 1 year ago

I am trying this to get the link to a file that is attached to a message to a channel:

$fileinfo = $MadelineProto->getDownloadInfo($message['media']);
$link = $MadelineProto->getDownloadLink($fileinfo["InputFileLocation"]["id"], $fileinfo["size"], $fileinfo["name"], $fileinfo["mime"]);

It breaks with the above error message, but the syntax is: $link = $MadelineProto->getDownloadLink($botApiFileId, size: $fileSize, name: $fileName, mime: $mimeType);

What am I doing wrong here?

danog commented 1 year ago

Use exactly the syntax specified in the example, named parameters must be used.

humpataa commented 1 year ago

Okay, now it breaks with "InvalidArgumentException: Invalid file type provided: 3900530663". As you can see, I am using the mime value of getDownloadInfo – which should be okay. My guess is that the file-id is not correct? Please advise.

danog commented 1 year ago

Wait sorry, I noticed you're doing something wrong, you just need to do $MadelineProto->getDownloadLink($message);