我想在我的本地主机SendPhoto
由webhook
。该图片不在电报服务器中。所以我需要通过多段头来上传它。电报SendPhoto方法does not工作
试图代码:
$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);
但它不能SendPhoto。
我已经在不同的网站上找到了解决方案,但是他们的代码与我的代码相同。
为什么不能正常工作?
我觉得这个解决方案可以解决您的问题,帮助http://stackoverflow.com/a/32844167/5348805 – Ars