This project demonstrates how to send SMS messages using a REST API with Java. The code utilizes Java's HttpURLConnection to make HTTP GET requests to the SMS gateway API endpoint.
- Sends SMS messages using REST API.
- URL encoding for message content.
- Displays API response and status codes.
- Java Development Kit (JDK) 8 or higher
- IDE (e.g., NetBeans, IntelliJ IDEA, or Eclipse)
├── build/classes/sendsms
├── lib
├── nbproject
├── src/sendsms
│ └── Sendsms.java
├── README.md
├── build.xml
└── manifest.mf
git clone https://github.com/ThaminduDisnaZ/Send-SMS-Using-Rest-API-on-JAVA.git
- Use an IDE like NetBeans or IntelliJ IDEA to open the project.
Edit the Sendsms.java file:
String token = "<your-api-token>";
String to = "<recipient-phone-number>";
String from = "<sender-id>";
String message = "<your-message>";- Compile the project.
- Run the main method in
Sendsms.java.
https://send.lk/sms/send.php
token- API token for authentication.to- Recipient's phone number.from- Sender ID.message- URL-encoded message text.
Response Code: 200
Response: {"status": "success", "message": "SMS sent successfully"}
This project is licensed under the MIT License. See the LICENSE file for more details.
Thamindu Disna
- GitHub: ThaminduDisnaZ
- Email: thamindudisna121@gmail.com