当前位置:网站首页>Wechat official account third-party platform development, zero foundation entry. I want to teach you
Wechat official account third-party platform development, zero foundation entry. I want to teach you
2022-06-30 08:13:00 【Code GuWa of nobody】
You should know before you learn the development of wechat third-party platform :
1, Use of common interface testing tools :postman
2, Learn to read third-party platform documents .( This is the key , But many still like Baidu , White whoring others' operation documents )
3, Learn to troubleshoot problems , To analyze problems .
4, Limitations of third-party platforms , And the official account , The relationship between subscription numbers should be understood . The test subscription number is not authenticated , Subscription numbers without authentication are very different .
5, Be good at using cache to solve business performance bottlenecks in projects .
Wechat open documents : Overview of wechat public platform development | Wechat open documents
The opening quotation :
Previous flowchart :

The third-party platform is equivalent to the configuration of our wechat official account , Initiate event listening through the configuration of the third-party platform , Contains callback information processing , We go through : Authorization event receiving configuration --》 Start push Ticket--》 Realize business after authorization --》 Message verification Token--》 Message and event receiving configuration --》 Wechat official account business
The process is so simple , But there are many interfaces , It's more difficult to operate , Still have to manage token Effectiveness . We finally need to get the permission of wechat official account token To achieve business turnaround , Otherwise everything else is bullshit .
Let's take a look at the page configuration and permissions of the third-party platform :

This is my own mapped domain name , After the official launch, change to the official domain name .
Access configuration :

Interfaces to be debugged :
There are many interfaces nacos To configure :
wechat:
config:
#appid
component_appid: *************
#aeskey
component_encodingaeskey: ****************
# verification token
component_token: ****************
# Encryption is formal
component_appsecret: ***********
# Authorized domain name
redirect_url: http://d1989091s1.51mypc.cn/wechat/preauth/callback
# obtain component_token url Address
api_component_url: https://api.weixin.qq.com/cgi-bin/component/api_component_token
# Create pre authorization url Address
api_create_preauth_url: https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=
# Permission query api Authorized platform address
api_query_auth_url: https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=
# verification token Refresh address
api_authorizer_token_url: https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=
# Media file download address
api_media_download_url: https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
# The customer service replies to the user's text message
api_message_custom_send_url: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=
# Get refresh token Address of the interface
api_refresh_url: https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=
#openid obtain unionid Address
api_unionid_batchget_url: https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=
# Get user information
api_unionid_get_url: https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
Code :
1, Obtain third-party platform authorization component_token
2, Obtain pre authorization api_create_preauthcode
3, After the wechat authorization platform obtains the permission interface according to the pre authorization token+ Scan Authorization code (api_query_auth)
4, Scan code to get queryauthcode
5, adopt queryauthcode Official account authorizer_token
6, adopt authorizer_token Operate official account business .
One , obtain component_token
Request address :https://api.weixin.qq.com/cgi-bin/component/api_component_token
Request parameters :
{
"component_appid":"********",
"component_appsecret":"****",
"component_verify_ticket":"[email protected]@@lKkaZ1rc4AL43879Kq7g4vmz8DrLdjWNtpnBoUl5tEJtcLhuSGTdayh4rZHxmRv12YB7CU_s7yQ"
}

"errmsg": "access clientip is not registered requestIP: 58.246.190.94 rid: 62b67820-316cbaee-50f9473e"
Need configuration ip White list :


Two , Obtain wechat pre authorization pre_auth_code
Request parameters :
{
"component_appid":"wx6ec5488b62c"
}
3、 ... and , The pre authorized token and component_appid And redirect the callback address back to html Page for authorization processing
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="" style="text-align:center;padding-top:10%;font-size:10em;">
<a href=https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=wx6ec5e8cec&[email protected]@@YWPYsD65xHdHMkKkSoXTx8W5sXhg3j0l_QfGx_r5lADHryjDH9nEn80ILQb-TBp0pq8Gn5&redirect_uri=http://d1989091s1.51mypc.cn/wechat/preauth/callback id="url"> Click to authorize </a>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" >
$(function () {
$.ajax({
url: "/wechat/auth/cache",
type: "post",
success: function (r) {
if (r.code == 0) {
var component_access_token = r.data.component_access_token;
var component_appid = r.data.component_appid;
var pre_auth_code = r.data.pre_auth_code;
var redirect_uri = r.data.redirect_uri;
var url = 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid='+component_appid
+'&pre_auth_code='+pre_auth_code+'&redirect_uri='+redirect_uri;
$('#url').attr('href',url);
} else {
alert(r.msg)
}
}
});
})
</script>
</body>
</html>
Authorized pages : Here is the administrator , Who certifies the subscription number , Just scan the code , If you do not have a official account, the subscription number is not bound , Then you can't authorize .



The permission here is the permission set opened by our third-party platform. You can open any permission function you need .
Four Update authorization callback .
<a href=https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=wx6ec5e8cec&[email protected]@@YWPYsD65xHdHMkKkSoXTx8W5sXhg3j0l_QfGx_r5lADHryjDH9nEn80ILQb-TBp0pq8Gn5&redirect_uri=http://d1989091s1.51mypc.cn/wechat/preauth/callback id="url"> Click to authorize </a>
## token url
redirect_uri=http://d1989091s1.51mypc.cn/wechat/preauth/callback
The callback address will return a auth_code Default one hour expiration , To prevent repeated scanning , You must get a refresh token, Timed brush cache , Guarantee token Don't expire .
http://d1989091s1.51mypc.cn/wechat/preauth/[email protected]@@*****&expires_in=3600
5、 ... and , The third-party platform obtains the authority of official account token
Parameters :
{
"component_appid":"********" ,
"authorization_code": "[email protected]@@KEm1qXN8KFuVWO05a3FhXhMtAGQp8RFA4dAEaldQ_ffdvsKIUtDWpVXtzu8dDH8D1DCMhAS61RmonKgPBjecUw"
}
Respond to :
{
"authorization_info": {
"authorizer_appid": "*********",
"authorizer_access_token": "58_PZeVA66EDTONWgd-8X9Miuu2dqFQ9FzFar4JTLahB5QmCIdSE1gY9BCYQVnJ8peVGm-1231L3oyIDZ92xlbpSbESN0aIlGW-6XfJXvDIWP6b_b-WW2yEM20AZkkHnECQHDMPiD0Uzqh6sCoHrVDjRPCcAFDVTG",
"expires_in": 7200,
"authorizer_refresh_token": "[email protected]@@UFuvwOxnZ0eXBGEghR9CD12DVTQnaZEwIQYBBGc6Oh89npg",
"func_info": [
{
"funcscope_category": {
"id": 1
},
"confirm_info": {
"need_confirm": 1,
"already_confirm": 0,
"can_confirm": 1
}
},
{
"funcscope_category": {
"id": 2
},
"confirm_info": {
"need_confirm": 1,
"already_confirm": 0,
"can_confirm": 1
}
},
{
"funcscope_category": {
"id": 4
}
},
{
"funcscope_category": {
"id": 6
}
},
{
"funcscope_category": {
"id": 7
}
},
{
"funcscope_category": {
"id": 9
}
},
{
"funcscope_category": {
"id": 15
}
}
]
}
}This authority token Default 2 Hours expired , So you need to refresh regularly to obtain permissions token
authorizer_refresh_token On behalf of us, we regularly refresh permissions token, This can help us solve the problem of repeated scanning , The administrator only needs to scan the code once .
6、 ... and . Official account authority token Refresh of
Request address :
Request parameters :
authorizer_appid Third party subscription number that requires authorization appid
component_appid Third-party platform appid
{
"component_appid":"wx6ec5e8ceb4882c",
"authorizer_appid":"wx3605b881a5f30b22"
} 
7、 ... and , By refreshing token Change the permission cache regularly
Request parameters :
{
"component_appid":"*******",
"authorizer_appid":"wxbe11fb37fd31d2cb",
"authorizer_refresh_token":"[email protected]@@UFuvwOxnZ0eXBGEghR9DVTQnaZEwIQYBBGc6Oh89npg"
}

authorizer_access_token Verify successful token This is the certificate we need to obtain for our official account .
Here we can call the interface directly according to the business of the official account . The overall process and implementation have been completed .
边栏推荐
- How to handle the expired data of redis and what are the elimination mechanisms?
- [nvme2.0b 14 - 5] commande de téléchargement / commande du logiciel
- 多快好省,低门槛AI部署工具FastDeploy测试版来了!
- 【NVMe2.0b 14-7】Set Features(上篇)
- Experiment 3 remote control
- 【NVMe2.0b 14-1】Abort、Asynchronous Event Request、Capacity Management command
- 【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
- Rendering engine development
- Cesium learning notes (VI) particle system
- 【NVMe2.0b 14-8】Set Features(下篇)
猜你喜欢

HelloWorld

What management improvements can CRM bring to enterprises

CRM&PM如何帮助企业创造最优销售绩效

End-to-end 3D Point Cloud Instance Segmentation without Detection

深度学习——GRU单元

你了解IP协议吗?

Full stack performance testing theory - Summary
![July 30, 2021 [wgs/gwas] - whole genome analysis process (Part I)](/img/37/ae0f7ca03ef564b029c9c709779231.jpg)
July 30, 2021 [wgs/gwas] - whole genome analysis process (Part I)

多快好省,低门槛AI部署工具FastDeploy测试版来了!

Hit the industry directly | the flying propeller launched the industry's first model selection tool
随机推荐
Environment configuration of ROS Aubo manipulator
Common tools installation, configuration, compilation, link, etc
Leetcode47. full arrangement II
Combinatorial mathematics Chapter 1 Notes
【NVMe2.0b 14-5】Firmware Download/Commit command
Dlib database face
HelloWorld
Game 280 problem2: minimum operands to turn an array into an alternating array
ACM. Hj48 delete the node with the specified value from the one-way linked list ●●
Deep learning - residual networks resnets
C. Fishingprince Plays With Array
Deep learning - networks in networks and 1x1 convolution
Introduction to opencv (II): image color space conversion and image saving
More, faster, better and cheaper. Here comes the fastdeploy beta of the low threshold AI deployment tool!
JS code case
深度学习——Bounding Box预测
swagger使用
【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
Why don't you know what to do after graduation from university?
【NVMe2.0b 14-2】Create/Delete Queue