Php 发送xls文件电报bot

Php 发送xls文件电报bot,php,telegram-bot,php-telegram-bot,Php,Telegram Bot,Php Telegram Bot,我正试图发送一个xls文件。在网上看了两个小时后,我不知道是哪里出错了。 我正在尝试从url发送此文件。这是我的密码 $filePath = $dburl."Last_season.xls"; $document = new CURLFile($filePath); $post = array('chat_id' => $callback_id_username,'document'=> $document,'caption' => $caption); $ch = curl

我正试图发送一个xls文件。在网上看了两个小时后,我不知道是哪里出错了。 我正在尝试从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);

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

通过URL发送-在sendDocument中,通过URL发送当前仅适用于gif、pdf和zip文件

请参阅botapi

要解决这个问题,您可以先将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];