go to telegram app on your phone, or log in with telegram web
and then search for bot father.
create a new bot /newbot
now follow along with instructions.
type a name for your bot
I had a hard time finding a username ( username must be botname_bot)
now you'll get a token to authenticate with your bot.
keep the access token securely. Anyone with access token can manipulate your bot
alright, now we have the access token. The next question is how to send messages with the bot.
we will create a group with our bot. And then our bot will massage to that group
it's simple as that
now let's create a new group in telegram and add the bot to that group.
search with the username of your bot .
add our bot to the group. after adding give admin permission to our bot, to give access to the bot to send messages to the group (not all the permissions are necessary but I will give because this is a demo group and nothing harmful will happen ).
now everything is set in this end.
The next thing we need is to get our group chat id to send messages to the group.
https://api.telegram.org/botBOT_API_KEy:BOT_ACCESS_TOCKEN/sendMessage?chat_id=@YOUR_BOT_NAME&text=YOUR_MESSAGE
run this code in browser.
OR
USe curl php code
<!------Code Start --->
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"https://api.telegram.org/botBOT_API_KEY:BOT_ACCESS_TOCKEN/sendMessage");
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"chat_id=@YOUR_BOT_NAME&text=Binance,$pair,BUY=$ask,Target=$r1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json'));
//curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
$result=curl_exec($ch);
curl_close($ch);
$result=json_decode($result);
echo"<pre>";
print_r($result);
<!---- code end ---->