我想SendPhoto
在我的本地主机中使用webhook
. 图片不在电报服务器中。所以我需要通过多部分标题上传它。
尝试的代码:
$file=fopen("Untitled.png","rb");
$cont=fread($file,filesize("Untitled.png"));
$headers=array("Content-type: multipart/form-data");
$postfields = array("chat_id" => "108432389", "photo" => "$file");
$ch = curl_init();
$options = array(
CURLOPT_URL => "https://api.telegram.org/bot(Token)/SendPhoto",
CURLOPT_HEADER => true,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $postfields,
CURLOPT_INFILESIZE => filesize("Untitled.png"),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => $headers
);
curl_setopt_array($ch, $options);
curl_exec($ch);
但它不能发送照片。
我在不同的网站上查看了解决方案,但是它们的代码与我的代码相同。
为什么这不起作用?