我想在我的本地主機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