需要三個步驟:
因此,我們需要引入redis和amqp:
org.springframework.boot
spring-boot-starter-data-redis
org.springframework.boot
spring-boot-starter-amqp
新增rabbitmq和redis配置:
spring:
redis:
host: 192.168.56.101
rabbitmq:
host: 192.168.56.101
username: learn
password: learn
virtual-host: /learn
另外還要用到工具類,生成6位隨機碼,這個我們封裝到了learn-common
中,因此需要引入依賴:
com.learn.common
learn-common
$
numberutils中有生成隨機碼的工具方法:
/**
* 生成指定位數的隨機數字
* @param len 隨機數的位數
* @return 生成的隨機數
*/public static string generatecode(int len)
在learn-user-service工程中的usercontroller新增方法:
/**
* 傳送手機驗證碼
}
在service中新增**:
@autowired
private stringredistemplate redistemplate;
@autowired
private amqptemplate amqptemplate;
static final string key_prefix = "user:code:phone:";
static final logger logger = logge***ctory.getlogger(userservice.class);
public boolean sendverifycode(string phone) catch (exception e) , code:{}", phone, code);
return false;
}}
注意:要設定簡訊驗證碼在redis的快取時間為5分鐘 Android呼叫系統簡訊功能傳送簡訊
android呼叫系統簡訊功能傳送簡訊有兩種方法,第一種,設定傳送的號碼,和內容,介面沒有聯絡人,群組組等按鈕,如下圖所示 如下 uri smstouri uri.parse smsto 114 聯絡人位址 intent mintent new intent android.content.inte...
C 實現傳送簡訊功能
1.從網上 申請賬號,記住使用者名稱,密碼會發到手機上,這僅是登陸密碼。註冊後會送5條簡訊 和3條彩信的傳送量。2.檢視sms簡訊通api下行介面 inese.cn api.shtml 然後獲取秘鑰,其實就是加密後的登入密碼。開始敲 相關 如下 using system using system.c...
簡訊傳送 簡訊傳送流程 應用層
簡訊傳送流程應用層解析 com.android.mms.ui.composemessageactivity com.android.mms.data.workingmessage com.android.mms.transaction.messagesender com.android.mms.tr...