進入阿里云市場頁面:登錄后,選擇API,

在API服務頁面選擇我需要的短信接口項,點擊進入

選擇看對眼的接口服務,

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

支付完成后,點擊進入管理控制臺,

控制臺有剛剛購買的服務的一些參數,最重要的是appcode,最為已購買的一個重要參數,用于在代碼中發(fā)送參數后,進行相應次數遞減的根據。

返回查看接口代碼。

復制頁面上提供的對應語言的? main 方法 ,

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

創(chuàng)建對應的java類

復制HttpUtils的代碼過來。

添加對應的依賴,
<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 自動導包, httpUtils自動導包,不再報錯。
在main方法的代碼上微調,修改appcode的值

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

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

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

手機收到的短信息:

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