当前位置:网站首页>Applet page generation link sent by SMS
Applet page generation link sent by SMS
2022-07-26 00:23:00 【Speed turtle】
One 、 background
There is an activity page that needs to send the page link through SMS , There is a official account QR code in the link , Users can scan the enterprise wechat QR code to add teachers to receive information .
Two 、 Implementation analysis
analysis : Because it is an enterprise wechat QR code, you need to open it in wechat . After initial analysis, the implementation methods may include the following :
- Click the activity page link in the SMS and pull up wechat , Then open it on wechat H5 page . Put the enterprise wechat QR code in the page, and then long press the user to identify .
- Click the link of the activity page in the SMS to pull up the wechat applet , You can jump in the applet h5, Then users can long press the QR code to identify enterprise wechat .
After analyzing the first method, no implementation scheme is found , The second kind of applet is officially given three implementation methods :
adopt URL Scheme Realization
Through the server interface or in the background of applet management URL Scheme after , Self developed transit H5 page .
Will have transit H5 The linked SMS content is delivered through the developer's own SMS sending ability or the service provider's SMS service , Realize SMS open applet .
adopt URL Link Realization
Generate through the server interface URL Link.
Directly with URL Link The SMS content of is delivered through the developer's own SMS sending ability or the SMS service of the service provider , Realize SMS open applet .
Through cloud development static website
You can refer to 「 Development of cloud 」-「 Static website 」-「 SMS jump applet 」.
After analysis, it is decided to adopt pass url link To achieve .
3、 ... and 、 Business implementation
1. First, develop a H5 The page will contain the two-dimensional code of enterprise wechat on h5 On the page .
This page only needs to follow UI The design can be developed normally .
2. Put the page into the applet
Create a new page in the applet , And then use web-view Tag nesting h5 page

At this time, the applet page is as follows :

3. Generate the current applet page according to the document url link.
At this time, the page path is “pages/index/index”
Generate according to the official documentation URL Link
public static final String URL_LINK_GENE_URL = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=ACCESS_TOKEN";
/**
* description: getAccessToken WeChat official account <br>
* version: 1.0 <br>
* @date: 2021/7/30 0030 Afternoon 2:18 <br>
* @author: William <br>
* @param appId WeChat AppID
* @param appSecret Wechat authorization key
* @return java.lang.String
*/
public static String getAccessToken(String appId,String appSecret) {
String token = null;
Lock lock = new ReentrantLock();
lock.lock();
try {
String requestTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=SECRET";
requestTokenUrl = requestTokenUrl.replace("APPID", appId);
requestTokenUrl = requestTokenUrl.replace("SECRET", appSecret);
WxTokenVo parse = JsonUtils.parse(HttpClientUtil.doGet(requestTokenUrl), WxTokenVo.class);
if(parse != null && StringUtils.isNotBlank(parse.getAccess_token())){
token = parse.getAccess_token();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock();
}
return token;
}
public static void main(String[] args) {
String accessToken = getAccessToken(WxtkConfig.LIVE_APP_ID, WxtkConfig.LIVE_APP_SECRET);
String requestUrl = URL_LINK_GENE_URL.replace("ACCESS_TOKEN",accessToken);
Map<String,Object> map = new HashMap<>();
map.put("path","pages/index/index");
map.put("query","");
map.put("env_version","release");
map.put("is_expire",true);
map.put("expire_type",1);
map.put("expire_interval",180);
// Need to introduce hutool Package or package one by yourself http Request tool class is also ok
String post = HttpUtil.post(requestUrl, JsonUtils.serialize(map));
System.out.println("post = " + post);
}After the request is successful, it will return url route , Then put the path into the SMS template and send it .

4. Put the... Of the applet page url link Put it in the SMS template , Then call the template to send .
OK. The above is the whole realization idea . Those who have better ideas or ideas can add wechat communication

边栏推荐
猜你喜欢
随机推荐
What is Web3 game?
Matlab makes the image of serial port output data in real time
Appium中控件元素封装类梳理
VMware ESXI7.0版本的安装与配置
URL address mapping configuration
【目录】mqtt、nodejs项目
Thymeleaf view integration
MySQL——多版本并发控制(MVCC)
FreeRTOS个人笔记-信号量
JVM 三色标记法与读写屏障
JSON data development
Four characteristics and isolation level of MySQL transactions
关于拼多多根据关键词取商品列表 API 的使用说明
寻找命令find和locate
拼多多根据ID取商品详情 API 的使用说明
mysql事务的四大特性以及隔离级别
Under inflation, how to operate in the future? 2021-05-14
Preparation of bovine erythrocyte superoxide dismutase sod/ folic acid coupled 2-ME albumin nanoparticles modified by bovine serum albumin
Binary representation -- power of 2
Unity -- Euler angle, quaternion









