You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.cdwaste.service;
  2. import org.springframework.stereotype.Service;
  3. import org.springframework.web.client.RestTemplate;
  4. import java.net.HttpURLConnection;
  5. import java.net.URL;
  6. @Service
  7. public class SMSService {
  8. public String sendMsg(String msgUrl) {
  9. System.out.println("Whatsapp URL :-"+msgUrl);
  10. String response ="";
  11. try{
  12. HttpURLConnection connection =null;
  13. URL url = new URL(msgUrl);
  14. connection = (HttpURLConnection) url.openConnection();
  15. connection.setRequestMethod("GET");
  16. int responseCode = connection.getResponseCode();
  17. response=responseCode+"";
  18. System.out.println("Response Code: " + responseCode);
  19. }catch (Exception e){
  20. e.printStackTrace();
  21. }
  22. return response;
  23. }
  24. public String sendSMS(String SMS_Url) {
  25. System.out.println("SMS URL:- "+ SMS_Url);
  26. RestTemplate restTemplate = new RestTemplate();
  27. String response =restTemplate.getForObject(SMS_Url,String.class);
  28. return response;
  29. }
  30. }