【问题标题】:Send xls file Telegram bot发送 xls 文件 Telegram bot
【发布时间】:2020-05-29 16:13:52
【问题描述】:

我正在尝试发送一个 xls 文件。上网查了2个小时,也没搞清楚是哪里出错了。 我正在尝试从 url 发送此文件。这是我的代码

$filePath = $dburl."Last_season.xls";
$document = new CURLFile($filePath);
$post = array('chat_id' => $callback_id_username,'document'=> $document,'caption' => $caption);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$GLOBALS[website]."/sendDocument");
curl_setopt($ch, CURLOPT_POST, 1);   
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result_curl = curl_exec ($ch);
curl_close ($ch);

【问题讨论】:

    标签: php telegram-bot php-telegram-bot


    【解决方案1】:

    目前不支持通过 url 发送 xls 文件。

    通过 URL 发送 - 在 sendDocument 中,通过 URL 发送目前仅适用于 gifpdfzip > 文件。

    请参阅机器人 API sending files

    要解决此问题,您可以先将 xls 文件存储在系统上并使用此文件 - 而不是 url。

    一种方法:

    $url_of_file = $dburl."Last_season.xls";
    $file_name = basename($url_of_file);
    file_put_contents( $file_name,file_get_contents($file_name)); //store xls file named "Last_season.xls" locally
    $document = new CURLFile($file_name);
    $post_data = ["chat_id" => ADMIN_CHAT_ID, "document" => $document];
    

    【讨论】:

      猜你喜欢
      • 2019-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-16
      • 2015-11-26
      • 1970-01-01
      • 1970-01-01
      • 2019-11-18
      相关资源
      最近更新 更多