我正在尝试发送xls文件。上网查看并在2个小时后,我不知道错误在哪里。 我正在尝试从网址发送此文件。这是我的代码
$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);
答案 0 :(得分:1)
当前不支持通过url发送xls文件。
按URL发送-在sendDocument中,按URL发送目前仅适用于 gif , pdf 和 zip >文件。
请参阅Bot 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];