【发布时间】:2018-04-22 16:03:43
【问题描述】:
我正在尝试从 Telegram BOT 发送 PDF。当我从服务器中选择文件时,它会显示以下消息:
Client error: `POST https://api.telegram.org/botXXXX/sendDocument` resulted in a `400 Bad Request` response:\n {"ok":false,"error_code":400,"description":"Bad Request: wrong file identifier/HTTP URL specified"}\
但是当我从其他服务器中选择时,它工作正常!
我的文件是这个目录:
http://109.169.XX.XX:7070/pdfs/sample.pdf
服务器端口应该是80吗?
代码:
$data=[
'chat_id' =>'YYYYY' ,
'caption' =>'test' ,
'document'=>"http://109.169.xx.xx:7070/pdfs/sample.pdf",
];
$url = 'https://api.telegram.org/bot' . $token . '/sendDocument';
$client= new \GuzzleHttp\Client([]);
$result = client->post( $url,['form_params'=>$data]);
【问题讨论】:
-
分享你的代码。
-
@Evert 代码添加
-
.pdf打开时返回什么mime类型? (Content-Type标头) -
@Evert MIME 类型:应用程序/pdf
标签: php telegram-bot php-telegram-bot