Need some help regarding Telegram Send Media Group to send multiple images to a group. I followed few steps given on stackoverflow previously, so far I can query the image path from MySQL & send images to the group, but unable to send multiple at once unless I loop the method inside my query result while loop, is there anyway to pass multiple images in one go using this method given below,i tried passing the query result to an array and pass to $postContent but still fails to send a media group.
$chatId="-123456";
$url = "https://api.telegram.org/botToken/sendMediaGroup";
$sqlq="SELECT webimgloc FROM Tpicture WHERE `id` = 11117723";
$resultset = mysqli_query($con, $sqlq) or die("database error:". mysqli_error($con));
while($rows = mysqli_fetch_array($resultset) )
{
$filePath1=$rows['webimgloc'];
$postContent = [
'chat_id' => $GLOBALS['chatId'],
'media' => json_encode([
['type' => 'photo', 'media' => 'attach://file.png' ],
]),
'file.png' => new CURLFile(realpath($filePath1))
];
post($url, $postContent);
}
post($url, $postContent);
function post($url, $postContent)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postContent);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}