0

I want to send a notification after firing an event in my website such as adding a post , adding a news or etc ...

I have done the requirements ,making a channel , adding a bot into it with administrtor role to send notification , get token , chat_id , finally I have made the link if I paste it in my browser's addressbar and press enter , that message will be send , but the problem is I can't run it automatically

here is my created Link :
https://api.telegram.org/bot[MY_Token]/sendMessage?chat_id=[MyChatId]&text=[My_TEXT] please help me ..

private function sendTelegram($token,$chat_id,$text){

$url = "https://api.telegram.org/bot".$token."/sendMessage?chat_id=".$chat_id."&text=".$text.""; file_get_contents($url); }

here is my error : failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Majid
  • 13
  • 6
  • Please add some code samples of what exactly you have tried so far, and any errors you have ancountered – Fabian Bettag Aug 11 '20 at 14:55
  • Did you encoded the url? If the 'text' contains spaces, the request will never reach the server if the url isn't escaped: [How to properly URL encode a string in PHP?](https://stackoverflow.com/questions/4744888/how-to-properly-url-encode-a-string-in-php) – 0stone0 Aug 11 '20 at 16:34
  • Why it works when I paste generated link in my browser ? I use just a simple word to send but I have error , I couldn't find any solution for my problem, I am confused , how no one haven't used this method for awaring their website users , that the website has broadcast new post or anything else ... – Majid Aug 11 '20 at 17:05
  • I Solved it by myself ! – Majid Aug 13 '20 at 07:53

0 Answers0