我正在尝试通过php发送图片到telegraph,但它不发送...
(The base64文件类型的图像)
- 联属萨摩亚**
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) );
?>
1条答案
按热度按时间ntjbwcob1#
把你的php代码改成这个,它应该可以工作