简体   繁体   English

如何将文件从服务器发送到电报机器人php

[英]how to send file from server to telegram bot php

I want to send an APK file from my server (URL) to my telegram bot 我想将APK文件从服务器(URL)发送到电报机器人

<?php 
    if ($update->callback_query->data == "app_dl"){
        $chat_id = $update->callback_query->message->chat->id;
        $document = "BQADBAAD2wADHg4hUfbD3f-YYGc3Ag";
        $caption = "text";
        var_dump(
            makeHTTPRequest('sendDocument',[
                'chat_id'=>$chat_id,
                'document'=> $document,
                'caption'=> $caption
            ])
        );  
    }
?>

I tried this one and send one APK file from telegram server to my bot but I want to send one APK file from my server to boot 我尝试了此操作,并从电报服务器向机器人发送了一个APK文件,但我想从服务器发送一个APK文件进行启动

If cURL is enabled ( check here ), you could try this: 如果启用了cURL请在此处检查 ),则可以尝试以下操作:

$filePath = 'myfile.apk'; // Relative path to a file in current directory
$document = new CURLFile(realpath($filePath));

Works perfect for me but you could also check here if it doesn't work for you. 对我来说很完美,但是您也可以在这里查看是否不适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM