-
-
Save ibrahimrajabli/5af34cfc5a80ff03c74ee8eb38128533 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.BufferedInputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.net.URL; | |
| import java.net.URLConnection; | |
| public class SendMessage { | |
| public static void sendToTelegram() { | |
| String urlString = "https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s"; | |
| //Add Telegram token (given Token is fake) | |
| String apiToken = "239287362:tyhERhehjr-dfg345gDFGWERWg245gwdfge"; | |
| //Add chatId (given chatId is fake) | |
| String chatId = "-210987654"; | |
| String text = "Hello world!"; | |
| urlString = String.format(urlString, apiToken, chatId, text); | |
| try { | |
| URL url = new URL(urlString); | |
| URLConnection conn = url.openConnection(); | |
| InputStream is = new BufferedInputStream(conn.getInputStream()); | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment