我正在尝试通过php将图片发送到电报,但是它不发送...
(base64文件类型中的图像)
JS:
var imagg;
function convertCanvasToImage(canvas) { // canvas = data:image/png;base64,iVBORw0....
var image = new Image();
image.src = canvas.toDataURL("image/png");
imagg = image.src;
return image;
}
setTimeout(function() {
$.post("telegram.php", {uu: imagg}, function(data) {
// returned from php
});
}, 5000);
PHP:
<?php
$uu = $_GET['uu'];
$apiToken = "TOKEN.....";
$data = [
'chat_id' => '@CHAT_ID...',
'photo' => $uu,
'caption' => 'Markdown'
];
$response = file_get_contents("https://api.telegram.org/bot$apiToken/sendPhoto?" . http_build_query($data) );
?>