【问题标题】:wrong file identifier/HTTP URL specified指定了错误的文件标识符/HTTP URL
【发布时间】: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


【解决方案1】:

我的问题已经解决了

我必须将我的代码从端口 7070 转移到端口 80

比如我的PDF文件地址是:

http://109.169.XX.XX/pdfs/sample.pdf

我建议如果你遇到这个问题,请确保你的代码运行在 80 端口,并且尽可能使用域而不是 IP

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-10
    • 2017-07-30
    • 2018-09-13
    • 1970-01-01
    • 2017-02-22
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多