JAVA code, Interface Example

SMS website most important function is to verify the software code interface. In order to secure a good user experience, companies will set up a verification code to your website or software gateways. When applying for membership or account, get a verification code text will appear. After clicking, they will receive a text message verification code. If you enter this code, the application will be successful. In this fast, simple way to maximize user safety.

So kewail small series put Java SMS interface code to share out, to provide major technical apes

package com.kewail.sdk.sms.v2;

import java.util.ArrayList;
import java.util.List;

import com.kewail.sdk.sms.v2.yun.SmsSingleSender;
import com.kewail.sdk.sms.v2.yun.SmsSingleSenderResult;

SmsSDKDemoV2 class {public
public static void main (String [] args) {
the try {
// SMS key address of the interface, [login kewail back page for]
// SMS key address of the interface, [login kewail back page for]
String = accesskey "xxx";
String SecretKey = "xxx";

    //type:0普通短信 1营销短信
    int type=0;
    //国家区号
    String nationcode="86";
    //手机号码
    String phoneNumber = "xxx";
    //短信签名ID [(登录kewail后台页面获取)
    String signId="5aa7ef278475af0e19b05f5b";
    //模板ID[(登录kewal后台页面获取)]
    String templateId="5a9599a56fcafe461546b953";
    //短信模板的变量值 ,将短信模板中的变量{0},{1}替换为参数中的值,如果短信模板中没有变量,则这个值填null
    List<String> params=new ArrayList<String>();
    //模板中存在多个可变参数,可以添加对应的值。
    params.add("362565");
    //自定义字段,用户可以根据自己的需要来使用
    String ext="";

     //初始化单发
    SmsSingleSender singleSender = new SmsSingleSender(accesskey, secretkey);
    SmsSingleSenderResult singleSenderResult;
     //普通单发,注意前面必须为【】符号包含,置于头或者尾部。
    singleSenderResult = singleSender.send(type, nationcode, phoneNumber, signId, templateId, params, ext);
    System.out.println(singleSenderResult);

    //语音验证码发送
    //SmsVoiceVerifyCodeSender smsVoiceVerifyCodeSender = new SmsVoiceVerifyCodeSender(accesskey,secretkey);
    //SmsVoiceVerifyCodeSenderResult smsVoiceVerifyCodeSenderResult = smsVoiceVerifyCodeSender.send("86",phoneNumber, "444144",2,"");
    //System.out.println(smsVoiceVerifyCodeSenderResult);

} catch (Exception e) {
    e.printStackTrace();
}

}

}

Guess you like

Origin blog.51cto.com/14349276/2404997