0
我創建了一個機器人,並且我想用我的機器人向我的客戶發送文件(文檔),使用以下代碼發送文檔後,標題將是我自己設備上文件的完整路徑(我的電腦),我怎樣才能改變標題文件名?這甚至有可能嗎?電報sendDocument api,更改標題
發送代碼:
protected function perform($method, $params) {
$url = new Url(TELEGRAM_API_URL . $this->bot->tokken . "/" . $method);
$fields = [];
foreach($params as $param => $val)
if($val != NULL && !cnull::is($val) && substr($param, 0, 1) != '_')
$fields[$param] = $val;
#
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url->getUrl());
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:multipart/form-data']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$out = curl_exec($ch);
curl_close($ch);
#
$content = json_decode($out);
return $content;
}
public function sendDocument($chat_id,$_document,$_is_file_id=false,$reply_to_message_id = NULL, $reply_markup = NULL) {
if($_is_file_id)
$document = $_document;
else
$document = new CURLFile(realpath($_document));
return self::perform(__FUNCTION__, get_defined_vars());
}
// ......
$tg->sendDocument(USER_CHAT_ID,"filename.mp4");