Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
814 stars 343 forks source link

Sending file from server to users! #106

Closed thezahedi closed 7 years ago

thezahedi commented 7 years ago

Hi,

How can I send files stored on server to users? Can you give me an example script?

Best.

saturn99 commented 7 years ago

see this doc

you must use sendDocument and set document parameters to file_id (file_id is file ID saved in telegrm server)

e.g:

$FILE_ID = YOUR FILE ID;
$a=array(
 'chat_id' => @isamanzahedi ,
 'document' => $FILE_ID
);
$t->sendDocument( $a );

to Persian: هر فایل روی سرور تلگرام یدونه فایل آیدی داره؛ اون رو بدست بیار و توسط کد بالا بفرست به سرور؛ خود تلگرام اون فایل آیدی رو تبدیل به فایل میکنه و میفرسته واسه مقصد

Eleirbag89 commented 7 years ago

To upload a file in the same server that runs the Bot, use

$file = curl_file_create('path/to/fle','mimetype/file'); 
$content = array('chat_id' => $chat_id, 'document' => $file );
$telegram->sendDocument($content);