I want to make a http get request to the telegram api to send a message to a channel (api.telegram.org) with PHP, but it doesn't work. I'm a PHP beginner, so maybe I'm doing something wrong
I event checked the "Server to Server" settings and the telegram api is on the whitelist so I should be able to make the request.
This is the code that i'm using (it works on the server on my local machine).
<?php
function send($key, $c, $t){
$url = "https://api.telegram.org/bot$key/sendMessage?parse_mode=HTML&chat_id=$c&text=$t";
file_get_contents($url);
}
send("bot token here", "chat id here", "text here");
?>
Could someone help me? Thank you