尝试通过php发送图片至电报

时间:2019-07-09 14:23:23

标签: javascript php telegram telegram-bot

我正在尝试通过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) );
?>

0 个答案:

没有答案