我试图用我的 Telegram 机器人将一些图像发送到一条消息中。我使用InputMediaPhoto方法发送,但不幸的是不起作用。
这是我的代码:
$url = "https://api.telegram.org/bot" . "TOKEN" . "/InputMediaPhoto";
$postContent = [
'chat_id' => $GLOBALS['chatId'],
'media' => [
['type'=>'photo' ,'media' => 'http://www.alcan5000.com/JPG/64Caliente.jpg'], //Just for test
['type' => 'photo' ,'media' => 'http://www.alcan5000.com/JPG/64Caliente.jpg'],
['type' => 'photo' ,'media' => 'http://www.alcan5000.com/JPG/64Caliente.jpg']
]
];
post($url, $postContent);
function post($url, $postContent)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postContent);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
浮云间