微信第三方平臺(tái)接口

第三方平臺(tái)開發(fā)流程

image.png

整個(gè)流程是第三方平臺(tái) 提供一個(gè)授權(quán)的頁面供公眾號(hào)|小程序管理員進(jìn)行授權(quán), 授權(quán)后第三方平臺(tái)將獲得 授權(quán)方(公眾號(hào)|小程序)的以下信息

authorization_info //授權(quán)信息
authorizer_appid  //授權(quán)方appid
authorizer_access_token   //access_token
expires_in
authorizer_refresh_token
func_info  // 授權(quán)的權(quán)限列表

然后用獲取的 authorizer_appid 及authorizer_access_token 代授權(quán)方調(diào)用相應(yīng)的接口

按開放平臺(tái)的文檔上說, 公眾號(hào)授權(quán)第三方平臺(tái)管理后,微信服務(wù)器會(huì)將粉絲發(fā)給公眾號(hào)的消息,以及微信服務(wù)器發(fā)給公眾號(hào)的事件推送(如自定義菜單點(diǎn)擊事件、粉絲取消關(guān)注通知等),發(fā)給開發(fā)者服務(wù)器(會(huì)發(fā)送到公眾號(hào)消息與事件接收URL,詳見申請(qǐng)資料說明頁)上 . 也就是說第三方平臺(tái)會(huì)接管消息接口 ,

關(guān)鍵參數(shù)

  1. component_verify_ticket
    第三方平臺(tái)創(chuàng)建審核通過后, 微信服務(wù)器每10分鐘推送給第三方平臺(tái)
<xml>
<AppId> </AppId>
<CreateTime>1413192605 </CreateTime>
<InfoType> </InfoType>
<ComponentVerifyTicket> </ComponentVerifyTicket>
</xml>
  1. component_access_token
    第三方平臺(tái)的所有接口都需要此token調(diào)用, 生成方式:
url:https://api.weixin.qq.com/cgi-bin/component/api_component_token
post:
{
    "component_appid": "appid_value",
    "component_appsecret": "appsecret_value",
    "component_verify_ticket": "ticket_value"
}
return:
{
    "component_access_token": "61W3mEpU66027wgNZ_MhGHNQDHnFATkDa9-2llqrMBjUwxRSNPbVsMmyD-yq8wZETSoE5NQgecigDrSHkPtIYA",
    "expires_in": 7200
}
  1. pre_auth_code
    預(yù)授權(quán)碼, 授權(quán)時(shí)的參數(shù), 生成方式:
url:
https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=xxx
post:
{
    "component_appid": "appid_value"
}

return:
{
    "pre_auth_code": "Cx_Dk6qiBE0Dmx4EmlT3oRfArPvwSQ-oa3NL_fwHM7VI08r52wazoZX2Rhpz1dEw",
    "expires_in": 600
}
  1. auth_code
    授權(quán)回調(diào)參數(shù), 生成方式
url:
 https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&component_appid=xxxx&pre_auth_code=xxxxx&redirect_uri=xxxx&auth_type=xxx&biz_appid=xxxx#wechat_redirect

return :
https://redirect_url/?auth_code=xxx&expires_in=600
  1. authorizer_appid , authorizer_access_token..
    用戶授權(quán)后 通過回調(diào)的 auth_code ,expires_in 獲取授權(quán)方的appid , access_token 用于代授權(quán)方公眾號(hào)|小程序調(diào)用接口
url:
https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=xxxx
post:
{
    "component_appid": "appid_value",
    "authorization_code": "auth_code"
}

return :
{
    "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
                }
            }
        ]
    }
}
  1. 刷新 authorizer_access_token
url:
https:// api.weixin.qq.com /cgi-bin/component/api_authorizer_token?component_access_token=xxxxx

post:
{
    "component_appid": "appid_value",
    "authorizer_appid": "auth_appid_value",
    "authorizer_refresh_token": "refresh_token_value"
}
reutrn :
{
    "authorizer_access_token": "aaUl5s6kAByLwgV0BhXNuIFFUqfrR8vTATsoSHukcIGqJgrc4KmMJ-JlKoC_-NKCLBvuU1cWPv4vDcLN8Z0pn5I45mpATruU0b51hzeT1f8",
    "expires_in": 7200,
    "authorizer_refresh_token": "BstnRqgTJBXb9N2aJq6L5hzfJwP406tpfahQeLNxX0w"
}
  1. 獲取授權(quán)帳號(hào)信息
url:
https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=xxxx
post:
{
    "component_appid": "appid_value",
    "authorizer_appid": "auth_appid_value"
}
return:
{
    "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": "騰訊計(jì)算機(jī)系統(tǒng)有限公司",
        "business_info": {
            "open_store": 0,
            "open_scan": 0,
            "open_pay": 0,
            "open_card": 0,
            "open_shake": 0
        },
        "alias": "paytest01",
        "qrcode_url": "URL"
    },
    "authorization_info": {
        "authorization_appid": "wxf8b4f85f3a794e77",
        "func_info": [
            {
                "funcscope_category": {
                    "id": 1
                }
            },
            {
                "funcscope_category": {
                    "id": 2
                }
            },
            {
                "funcscope_category": {
                    "id": 3
                }
            }
        ]
    }
}

  1. 獲取授權(quán)方的選項(xiàng)設(shè)置信息
url:
https://api.weixin.qq.com/cgi-bin/component/ api_get_authorizer_option?component_access_token=xxxx
post:
{
    "component_appid": "appid_value",
    "authorizer_appid": " auth_appid_value ",
    "option_name": "option_name_value"
}

return:
{
    "authorizer_appid": "wx7bc5ba58cabd00f4",
    "option_name": "voice_recognize",
    "option_value": "1"
}

option 值:

option_name option_value 選項(xiàng)值說明
location_report(地理位置上報(bào)選項(xiàng)) 0 無上報(bào)
location_report(地理位置上報(bào)選項(xiàng)) 1 進(jìn)入會(huì)話時(shí)上報(bào)
location_report(地理位置上報(bào)選項(xiàng)) 2 每5s上報(bào)
voice_recognize(語音識(shí)別開關(guān)選項(xiàng)) 0 關(guān)閉語音識(shí)別
voice_recognize(語音識(shí)別開關(guān)選項(xiàng)) 1 開啟語音識(shí)別
customer_service(多客服開關(guān)選項(xiàng)) 0 關(guān)閉多客服
customer_service(多客服開關(guān)選項(xiàng)) 1 開啟多客服
  1. 設(shè)置授權(quán)方的選項(xiàng)信息
url:
https://api.weixin.qq.com/cgi-bin/component/ api_set_authorizer_option?component_access_token=xxxx
post:
{
"component_appid":"appid_value",
"authorizer_appid": " auth_appid_value ",
"option_name": "option_name_value",
"option_value":"option_value_value"
}
return:
{
"errcode":0,
"errmsg":"ok"
}
  1. 授權(quán)通知
    公眾號(hào)|小程序在授權(quán)頁進(jìn)行操作時(shí), 微信服務(wù)器將事件推送給第三方平臺(tái)設(shè)定的url
  • . 授權(quán)成功
<xml>
<AppId>第三方平臺(tái)appid</AppId>
<CreateTime>1413192760</CreateTime>
<InfoType>authorized</InfoType>
<AuthorizerAppid>公眾號(hào)appid</AuthorizerAppid>
<AuthorizationCode>授權(quán)碼(code)</AuthorizationCode>
<AuthorizationCodeExpiredTime>過期時(shí)間</AuthorizationCodeExpiredTime>
<PreAuthCode>預(yù)授權(quán)碼</PreAuthCode>

<xml>
  • . 取消授權(quán)
<xml>
<AppId>第三方平臺(tái)appid</AppId>
<CreateTime>1413192760</CreateTime>
<InfoType>unauthorized</InfoType>
<AuthorizerAppid>公眾號(hào)appid</AuthorizerAppid>

</xml>
  • . 更新授權(quán)
<xml>
<AppId>第三方平臺(tái)appid</AppId>
<CreateTime>1413192760</CreateTime>
<InfoType>updateauthorized</InfoType>
<AuthorizerAppid>公眾號(hào)appid</AuthorizerAppid>
<AuthorizationCode>授權(quán)碼(code)</AuthorizationCode>
<AuthorizationCodeExpiredTime>過期時(shí)間</AuthorizationCodeExpiredTime>
<PreAuthCode>預(yù)授權(quán)碼</PreAuthCode>
<xml>
-- --
字段名稱 字段描述
AppId 第三方平臺(tái)appid
CreateTime 時(shí)間戳
InfoType unauthorized是取消授權(quán),updateauthorized是更新授權(quán),authorized是授權(quán)成功通知
AuthorizerAppid 公眾號(hào)或小程序
AuthorizationCode 授權(quán)碼,可用于換取公眾號(hào)的接口調(diào)用憑據(jù),詳細(xì)見上面的說明
AuthorizationCodeExpiredTime 授權(quán)碼過期時(shí)間
PreAuthCode 預(yù)授權(quán)碼
  1. 拉取當(dāng)前所有已授權(quán)的帳號(hào)基本信息
url:
https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_list?component_access_token=COMPONENT_ACCESS_TOKEN
post:
{
    "component_appid": "appid_value",
    "offset": 0,
    "count": 100
}

return:
{
    "total_count": 33,
    "list": [
        {
            "authorizer_appid": "authorizer_appid_1",
            "refresh_token": "refresh_token_1",
            "auth_time": "auth_time_1"
        },
        {
            "authorizer_appid": "authorizer_appid_2",
            "refresh_token": "refresh_token_2",
            "auth_time": "auth_time_2"
        }
    ]
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容