【发布时间】:2020-09-17 01:11:39
【问题描述】:
我正在使用标准 Telegram Bot API 发送消息。当照片 url 包含像右单引号 (') 和左单引号 (') 这样的特殊字符时,不会发送消息,因为它是错误请求。
运行 php rawurlencode 时,’ 显示为 %E2%80%99 和 ‘ 显示为 %E2%80%98
$photourl='https://example.com/some/path/name-of-image-with‘quotes’.jpg';
$array =[
'chat_id' => $uid,
'photo' => $photourl,
'caption' => $caption
];
file_get_contents("https://api.telegram.org/bot$api/sendPhoto?".http_build_query($array) );
它给出了一个
PHP 警告 -- 无法打开流:HTTP 请求失败! HTTP/1.1 400 错误请求
【问题讨论】:
标签: url telegram-bot sendmessage