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?
/* * * 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.
- Related articles
- How to set the disconnection notification function of Xiaomi watch s 1pro
- Minsheng Bank credit card has passed the preliminary examination and final examination, and will send a text message within three working days.
- Gitzo company repayment SMS
- How to write at the end of an application letter
- What's wrong with these short messages received every day?
- What happened when the bank card of Agricultural Bank of China at the beginning of 623052 bound Alipay didn't receive the verification code?
- If you haven’t downloaded Bubble Chat, will it send text messages for authentication?
- Full refund skills for flying pig tickets
- Blessings for Entering Futian Blessings about entering Futian
- Questions about accounting basics