|
進(jìn)入阿里云市場(chǎng)頁面:登錄后,選擇API,

在API服務(wù)頁面選擇我需要的短信接口項(xiàng),點(diǎn)擊進(jìn)入

選擇看對(duì)眼的接口服務(wù),

如果是試用就選擇0元/5次,如果有錢不愁花就選擇30000元/100000次的購買

支付完成后,點(diǎn)擊進(jìn)入管理控制臺(tái),

控制臺(tái)有剛剛購買的服務(wù)的一些參數(shù),最重要的是appcode,最為已購買的一個(gè)重要參數(shù),用于在代碼中發(fā)送參數(shù)后,進(jìn)行相應(yīng)次數(shù)遞減的根據(jù)。

返回查看接口代碼。

復(fù)制頁面上提供的對(duì)應(yīng)語言的? main 方法 ,

創(chuàng)建云工具的包,與api接口的utils對(duì)應(yīng)

創(chuàng)建對(duì)應(yīng)的java類

復(fù)制HttpUtils的代碼過來。

添加對(duì)應(yīng)的依賴,
<dependencies>
<!-- <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-hc</artifactId>
<version>3.1.10</version> </dependency> -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.3.7.v20160115</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
Ctrl shirt o 自動(dòng)導(dǎo)包, httpUtils自動(dòng)導(dǎo)包,不再報(bào)錯(cuò)。
在main方法的代碼上微調(diào),修改appcode的值

管理中心有已購買后生成的appcode,換掉就好

可用于發(fā)送參數(shù)的位置,如發(fā)送驗(yàn)證碼等。

配置完成后,啟動(dòng)main方法,返回執(zhí)行成功的resultType

手機(jī)收到的短信息:

?
鏈接:https://pan.baidu.com/s/1poKCr0hjw6xFUWIPoq-4xg
提取碼:u0dp
復(fù)制這段內(nèi)容后打開百度網(wǎng)盤手機(jī)App,操作更方便哦
來源:http://www./content-4-156751.html
|