完善c端接口

This commit is contained in:
menxipeng
2025-07-19 14:20:38 +08:00
parent 40f49732a6
commit 028ccf4408
34 changed files with 1278 additions and 126 deletions

View File

@@ -63,12 +63,12 @@ public class AliConfig {
//String templateParam = "{\"name\":\"" + shopUser.getUsername() + "\",\"number\":\""+ shopUser.getPhone() +"\"}";
String templateParam = "您的验证码为:"+ shopUser.getCode() +",请勿泄露于他人!";
String templateParam = "{'code':"+ code + "}";
// 构造API请求对象请替换请求参数值
SendSmsRequest sendSmsRequest = new SendSmsRequest()
.setPhoneNumbers(shopUser.getPhone())
.setSignName("阿里云短信测试")
.setSignName("北京盛兴平商贸")
.setTemplateCode("SMS_323405385")
.setTemplateParam(templateParam); // TemplateParam为序列化后的JSON字符串。

View File

@@ -10,12 +10,12 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@@ -25,10 +25,10 @@ import java.util.Map;
@Component
public class UmengConfig {
public CloseableHttpResponse send(String token){
String umAppkey = "xxxx";
String appKey = "5df88f83570df3b8d40012337";
String appSecret = "xxxx";
public static CloseableHttpResponse send(String token){
String umAppkey = "5df88f83570df3b8d40012337";
String appKey = "LTAI5tDWWzwqxumUXTFnkQFd";
String appSecret = "KOD3y6OxbHJ23wxAf68NFpUQXCQEPX";
// 下面的url要和阿里云云市场购买的商品对应
String url = "https://verify5.market.alicloudapi.com/api/v1/mobile/info?appkey=" + umAppkey;
HttpPost httpPost = new HttpPost(url);
@@ -85,8 +85,11 @@ public class UmengConfig {
public static void main(String[] args) throws InvalidKeyException, NoSuchAlgorithmException {
public static void main(String[] args) throws IOException {
CloseableHttpResponse sss = send("1234");
String reponseContent = EntityUtils.toString(sss.getEntity());
System.out.println(reponseContent);
System.out.println(sss.getStatusLine().getReasonPhrase());
}
private static String getSignString(HttpPost httpPost) {