开放平台账号信息
--------------------------------------
component_appid
component_appsecret
compoment_encodingaeskey
compoment_token
--------------------------------------
缓存结构
--------------------------------------
* component_verify_ticket: ${component_appid}, ${ComponentVerifyTicket}
* ${component_appid}: {
"component_access_token": ${component_access_token},
"expires_in": ${new Date() + 6600s},
"component_appsecret": ${component_appsecret},
"compoment_encodingaeskey": ${compoment_encodingaeskey},
"compoment_token": ${compoment_token}
}
* ${authorizer_appid}: {
"authorizer_access_token": ${authorizer_access_token},
"expires_in": ${new Date() + 6600s},
"authorizer_refresh_token": ${authorizer_refresh_token},
}
* SaasWxAppIdList{[
${authorizer_appid}: {
"authorizer_access_token": ${authorizer_access_token},
"expires_in": ${new Date() + 6600s},
"authorizer_refresh_token": ${authorizer_refresh_token},
}
]}
* AppIdAndStoreMapping: {[
${tenantid}_${store_id}:${authorizer_appid}
]}
*
-- "pre_auth_code": {"pre_auth_code":${pre_auth_code}, "expires_in": ${new Date() + 550s}},
-- "authorization_code": {"authorization_code":${authorization_code}, "expires_in": ${new Date() + 550s}},
--------------------------------------
开发步骤整理
--------------------------------------
1. 推送 component_verify_ticket 协议
主动接收: component_verify_ticket 商户级(10分钟/次)
<xml>
<AppId> </AppId>
<CreateTime>1413192605 </CreateTime>
<InfoType> </InfoType>
<ComponentVerifyTicket> </ComponentVerifyTicket>
</xml>
注意: 接收到后必须直接返回字符串success
--------------------------------------
2. 获取第三方平台component_access_token
前提:
component_verify_ticket 商户级(10分钟/次)
component_appid
component_appsecret
结果:
component_access_token
{
"component_access_token":"61W3mEpU66027wgNZ_MhGHNQDHnFATkDa9-2llqrMBjUwxRSNPbVsMmyD-yq8wZETSoE5NQgecigDrSHkPtIYA",
"expires_in":7200
}
--------------------------------------
3. 获取预授权码pre_auth_code
前提:
component_access_token
component_appid
结果:
pre_auth_code
{
"pre_auth_code":"Cx_Dk6qiBE0Dmx4EmlT3oRfArPvwSQ-oa3NL_fwHM7VI08r52wazoZX2Rhpz1dEw",
"expires_in":600
}
--------------------------------------
4. 获取授权码 [authorization_code]
前提:[用户同意授权]
例子: [https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=xxxx&pre_auth_code=xxxxx&redirect_uri=xxxx]
component_appid
pre_auth_code
redirect_uri
结果: 授权流程完成后,授权页会自动跳转进入回调URI,并在URL参数中返回授权码和过期时间(redirect_url?auth_code=xxx&expires_in=600)
注意: 此时回调回来的参数与后边调用的参数名称不一致 [auth_code -->> authorization_code], [把auth_code放到redis中,值为商户号,为授权通知准备数据源, 60s]
authorization_code
同时会接收授权推送信息 InfoType: [unauthorized(取消授权通知), authorized(授权成功通知), updateauthorized(授权更新通知)]
<xml>
<AppId>第三方平台appid</AppId>
<CreateTime>1413192760</CreateTime>
<InfoType>authorized</InfoType>
<AuthorizerAppid>公众号appid</AuthorizerAppid>
<!-- 后边三项取消授权是没有的 -->
<AuthorizationCode>授权码(code)</AuthorizationCode>
<AuthorizationCodeExpiredTime>过期时间</AuthorizationCodeExpiredTime>
<PreAuthCode>预授权码</PreAuthCode>
</xml>
加: 异步通知写定时任务处理 [判断回调有没有授权] (可选)
--------------------------------------
5. 使用授权码换取公众号或小程序的接口调用凭据和授权信息
前提:
component_access_token
component_appid
authorization_code
结果:
authorizer_access_token
{
"authorization_info": {
"authorizer_appid": "wxf8b4f85f3a794e77",
"authorizer_access_token": "QXjUqNqfYVH0yBE1iI_7vuN_9gQbpjfK7hYwJ3P7xOa88a89-Aga5x1NMYJyB8G2yKt1KCl0nPC3W9GJzw0Zzq_dBxc8pxIGUNi_bFes0qM",
"expires_in": 7200,
"authorizer_refresh_token": "dTo-YCXPL4llX-u1W1pPpnp8Hgm4wpJtlR6iV0doKdY",
"func_info": [
{"funcscope_category": {"id": 1}},
{"funcscope_category": {"id": 2}},
{"funcscope_category": {"id": 3}}
]
}
}
* 保存数据库,及缓存
--------------------------------------
6. 获取(刷新)授权公众号或小程序的接口调用凭据(令牌)
前提:
component_access_token
component_appid
authorizer_appid
authorizer_refresh_token
结果:
{
"authorizer_access_token": "aaUl5s6kAByLwgV0BhXNuIFFUqfrR8vTATsoSHukcIGqJgrc4KmMJ-JlKoC_-NKCLBvuU1cWPv4vDcLN8Z0pn5I45mpATruU0b51hzeT1f8",
"expires_in": 7200,
"authorizer_refresh_token": "BstnRqgTJBXb9N2aJq6L5hzfJwP406tpfahQeLNxX0w"
}
--------------------------------------
7. 获取授权方的帐号基本信息
前提:
component_access_token
component_appid
authorizer_appid
结果:
{
"authorizer_info": {
"nick_name": "微信SDK Demo Special",
"head_img": "http://wx.qlogo.cn/mmopen/GPy",
"service_type_info": { "id": 2 },
"verify_type_info": { "id": 0 },
"user_name":"gh_eb5e3a772040",
"principal_name":"腾讯计算机系统有限公司",
"business_info": {"open_store": 0, "open_scan": 0, "open_pay": 0, "open_card": 0, "open_shake": 0},
"alias":"paytest01"
"qrcode_url":"URL",
},
"authorization_info": {
"appid": "wxf8b4f85f3a794e77",
"func_info": [
{ "funcscope_category": { "id": 1 } },
{ "funcscope_category": { "id": 2 } },
{ "funcscope_category": { "id": 3 } }
]
}
}
* 保存数据库,及缓存
--------------------------------------
8. 获取授权方的选项设置信息
前提:
component_access_token
component_appid
authorizer_appid
option_name
结果:
{
"authorizer_appid":"wx7bc5ba58cabd00f4",
"option_name":"voice_recognize",
"option_value":"1"
}
--------------------------------------
9. 设置授权方的选项信息
前提:
component_access_token
component_appid
authorizer_appid
option_name
option_value
结果:
{
"errcode":0,
"errmsg":"ok"
}
--------------------------------------
location_report(地理位置上报选项) 0 无上报
1 进入会话时上报
2 每5s上报
voice_recognize(语音识别开关选项) 0 关闭语音识别
1 开启语音识别
customer_service(多客服开关选项) 0 关闭多客服
1 开启多客服
=============================================================