Joke Collection Website - Blessing messages - How does java realize the function of sending SMS verification code?

How does java realize the function of sending SMS verification code?

1. Create an Http mock request tool class, and then write a POST method or a GET method.

/* * * file description * @Description: extended description * @ copyright: xxxx dreamtech.com.cn company all rights reserved * @ version: v6.0 */packagecom.demo.util; Import java.io.ioexception; Import java.util.map; Importorg.apache.com mons.inc. All rights reserved * @ version: v6.0 */packagecomm.demo.util; Import java.net.urlencoder; Import java.util.hashmap; Import java.util.map; /* * * @ Author: feizi * @ Date: XXXX, XX, XX: XX * @ modifyuser: feizi * @ modifydate: xxxx, xx, Xx: xx * @ version: v6.0 */public classsendmsgutil {/* Send SMS * Description * @ Discription: Extended Description * @ ParaPhones * @ ParaContent * @ Return * @ Return String * @ Author: feizi * @ Date: 201April 517th 7: 65437 @ suppressed warnings ("recession") public static string send msg (string phones, String Content) {//SMS interface url submission address String url = "SMS interface URL submission address "; Map & ltString, String & gtparams = new hashmap & lt string, string & gt (); Params.put("zh ","user account "); Params.put("mm ","user password "); Params.put("dxlbid ","SMS category number "); Params.put("extno ","extension number "); //mobile phone number, multiple numbers are separated by English commas params.put("hm ",Phones); //URLEncoder SMS params.put ("NR ",URL encoder.encode (content)); Returns HttpRequestUtil.getRequest(url, params); }/* * Randomly generate 6-digit random verification code * Method description * @ description: extended description * @ return * @ return string * @ author: feizi * @ date: 2015aapril17at7:/ kloc-0/9:02 * @ modifyuser:Feizi * @ modify Date:20 17 April 15 7: 19:02 */public staticfor(int I = 0; I<6; i++){ vcode = vcode+(int)(math . random()* 9); } returns vcode}/* * Test * method description * @ description: extended description * @ paraargs * @ returnvoid * @ author: feizi * @ date: XX, xx, XX:XX * @ Modifyuser:Feizi * @ modify Date:XX,XXxx,XX:XX */public static Void main(string[]args){//system . out . println(sendmsgutil . createrandomvcode()); //system . out . println(& amp; ecb= 12”。 Substring (1)); System. Out.println (sendmsg ("18123456789, 15 123456789"), "Dear user, your verification code is" +sendmsgutil ". Creatrandomvcode ()+",valid for 60 seconds. }

Then execute it. Under normal circumstances, if the parameters are passed correctly and operated according to the specification of the interface file, it will be sent successfully and the mobile phone can receive the verification code. Then the possible problem is that the content of the short message sent may be garbled in Chinese, and then it will not be successful. Just code according to the requirements of the SMS platform. It is usually UTF 8 encoding.