sending message in telegram bot using curl sending message in telegram bot using curl curl curl

sending message in telegram bot using curl


In curl method you should NOT use any data in url.as you see your url that get error has spaces that is not valid. This is a working curl code:

$website="https://api.telegram.org/bot".$botToken;$chatId=1234567;  //Receiver Chat Id $params=[    'chat_id'=>$chatID,    'text'=>'MoonLight',];$ch = curl_init($website . '/sendMessage');curl_setopt($ch, CURLOPT_HEADER, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);$result = curl_exec($ch);curl_close($ch);