TG机器人发送图片文件示例

<?php
$chat_id = '-10**3359**140';
$bot_id = '10286*****:AAHoZ5sFF1rTP**x8**k5u*KKF8*MWpyA**';
$bot_url    = "https://api.telegram.org/bot{$bot_id}/";
$url        = $bot_url . "sendPhoto?chat_id=" . $chat_id . "&caption=关公千里走单骑";

$post_fields = array('chat_id'   => $chat_id,
    'photo'     => new CURLFile(realpath("gg.jpg"))
);

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-Type:multipart/form-data"
));
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); 
$output = curl_exec($ch);

本文链接:

http://logs.ee/coding/20191207/7.html
1 + 9 =
快来做第一个评论的人吧~