真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

微信web協(xié)議的示例分析-創(chuàng)新互聯(lián)

這篇文章主要介紹微信web協(xié)議的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

專注于為中小企業(yè)提供網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)博興免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了成百上千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

微信web協(xié)議分析(微信網(wǎng)頁(yè)版 wx2.qq.com)

1.打開(kāi)首頁(yè),分配一個(gè)隨機(jī)uuid,
2.根據(jù)該uuid獲取二維碼圖片。
3.微信客戶端掃描該圖片,在客戶端確認(rèn)登錄。
4.瀏覽器不停的調(diào)用一個(gè)接口,如果返回登錄成功,則調(diào)用登錄接口
5.此時(shí)可以獲取聯(lián)系人列表,可以發(fā)送消息。然后不斷調(diào)用同步接口。
6.如果同步接口有返回,則可以獲取新消息,然后繼續(xù)調(diào)用同步接口。

源碼地址:github.com/biezhi/wechat-robot

執(zhí)行流程

       +--------------+     +---------------+   +---------------+
       |              |     |               |   |               |
       |   Get UUID   |     |  Get Contact  |   | Status Notify |
       |              |     |               |   |               |
       +-------+------+     +-------^-------+   +-------^-------+
               |                    |                   |
               |                    +-------+  +--------+
               |                            |  |
       +-------v------+               +-----+--+------+      +--------------+
       |              |               |               |      |              |
       |  Get QRCode  |               |  Weixin Init  +------>  Sync Check  <----+
       |              |               |               |      |              |    |
       +-------+------+               +-------^-------+      +-------+------+    |
               |                              |                      |           |
               |                              |                      +-----------+
               |                              |                      |
       +-------v------+               +-------+--------+     +-------v-------+
       |              | Confirm Login |                |     |               |
+------>    Login     +---------------> New Login Page |     |  Weixin Sync  |
|      |              |               |                |     |               |
|      +------+-------+               +----------------+     +---------------+
|             |
|QRCode Scaned|
+-------------+

WebWechat API

1. 獲取UUID(參考方法 getUUID)

API獲取 UUID
url/tupian/20230522/tdtdURL Encode
paramsappid : wx782c26e4c19acffb
fun : new
lang: zh_CN
_ : 時(shí)間戳

返回?cái)?shù)據(jù)(String):

window.QRLogin.code = 200; window.QRLogin.uuid = "xxx"

2. 顯示二維碼(參考方法 showQrCode)

API顯示二維碼
urllogin.weixin.qq.com/qrcode/{uuid}
methodPOST
paramst : webwx
_ : 時(shí)間戳


3. 等待登錄(參考方法 waitForLogin)這里是微信確認(rèn)登錄

API二維碼掃描登錄
urllogin.weixin.qq.com/cgi-bin/mmwebwx-bin/login
methodGET
paramstip : 1:未掃描 0:已掃描
uuid : 獲取到的uuid
_ : 時(shí)間戳

返回?cái)?shù)據(jù)(String):

window.code=xxx;

xxx:    408 登陸超時(shí)    201 掃描成功    200 確認(rèn)登錄

當(dāng)返回200時(shí),還會(huì)有
window.redirect_uri="/tupian/20230522/webwxnewloginpage 登錄獲取Cookie(參考方法 login)
APIwebwxnewloginpage
urlwx2.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage
methodGET
paramsticket : xxx
uuid : xxx
lang : zh_CN
scan : xxx
fun : new

返回?cái)?shù)據(jù)(XML):


    0
    OK
    xxx
    xxx
    xxx
    xxx
    1

在這一步獲取xml中的skey,wxsid,wxuin,pass_ticket

5. 微信初始化(參考方法 wxInit)

APIwebwxinit
urlwx2.qq.com/cgi-bin/mmwebwx-bin/webwxinit
methodPOST
dataJSON
headerContent-Type: application/json; charset=UTF-8
params{
    BaseRequest: {
        Uin: xxx,
        Sid: xxx,
        Skey: xxx,
        DeviceID: xxx,
    }
}

返回?cái)?shù)據(jù)(JSON):

{
    "BaseResponse": {
        "Ret": 0,
        "ErrMsg": ""
    },
    "Count": 11,
    "ContactList": [...],
    "SyncKey": {
        "Count": 4,
        "List": [
            {
                "Key": 1,
                "Val": 635705559
            },
            ...
        ]
    },
    "User": {
        "Uin": xxx,
        "UserName": xxx,
        "NickName": xxx,
        "HeadImgUrl": xxx,
        "RemarkName": "",
        "PYInitial": "",
        "PYQuanPin": "",
        "RemarkPYInitial": "",
        "RemarkPYQuanPin": "",
        "HideInputBarFlag": 0,
        "StarFriend": 0,
        "Sex": 1,
        "Signature": "Apt-get install B",
        "AppAccountFlag": 0,
        "VerifyFlag": 0,
        "ContactFlag": 0,
        "WebWxPluginSwitch": 0,
        "HeadImgFlag": 1,
        "SnsFlag": 17
    },
    "ChatSet": xxx,
    "SKey": xxx,
    "ClientVersion": 369297683,
    "SystemTime": 1453124908,
    "GrayScale": 1,
    "InviteStartCount": 40,
    "MPSubscribeMsgCount": 2,
    "MPSubscribeMsgList": [...],
    "ClickReportInterval": 600000
}

這一步中獲取SyncKey,User 后面的消息監(jiān)聽(tīng)用。

6. 開(kāi)啟微信狀態(tài)通知(參考方法 wxStatusNotify)

APIwebwxstatusnotify
urlwx2.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify
methodPOST
dataJSON
headerContent-Type: application/json; charset=UTF-8
params{
    BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
    Code: 3,
    FromUserName: 自己的ID,
    ToUserName: 自己的ID,
    ClientMsgId: 時(shí)間戳
}

返回?cái)?shù)據(jù)(JSON):

{
    "BaseResponse": {
        "Ret": 0,
        "ErrMsg": ""
    },
    ...
}

7. 獲取聯(lián)系人列表(參考方法 getContact)

APIwebwxgetcontact
urlwx2.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8
params{
    BaseRequest: {
        Uin: xxx,
        Sid: xxx,
        Skey: xxx,
        DeviceID: xxx,
    }
}

返回?cái)?shù)據(jù)(JSON):

{
    "BaseResponse": {
        "Ret": 0,
        "ErrMsg": ""
    },
    "MemberCount": 334,
    "MemberList": [
        {
            "Uin": 0,
            "UserName": xxx,
            "NickName": "Urinx",
            "HeadImgUrl": xxx,
            "ContactFlag": 3,
            "MemberCount": 0,
            "MemberList": [],
            "RemarkName": "",
            "HideInputBarFlag": 0,
            "Sex": 0,
            "Signature": "我是二蛋",
            "VerifyFlag": 8,
            "OwnerUin": 0,
            "PYInitial": "URINX",
            "PYQuanPin": "Urinx",
            "RemarkPYInitial": "",
            "RemarkPYQuanPin": "",
            "StarFriend": 0,
            "AppAccountFlag": 0,
            "Statues": 0,
            "AttrStatus": 0,
            "Province": "",
            "City": "",
            "Alias": "Urinxs",
            "SnsFlag": 0,
            "UniFriend": 0,
            "DisplayName": "",
            "ChatRoomId": 0,
            "KeyWord": "gh_",
            "EncryChatRoomId": ""
        },
        ...
    ],
    "Seq": 0
}

8.消息檢查(參考方法 syncCheck)

APIsynccheck
urlwebpush3.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck
methodGET
dataJSON
headerContentType: application/json; charset=UTF-8
params{
    BaseRequest: {
        Uin: xxx,
        Sid: xxx,
        Skey: xxx,
        DeviceID: xxx,
    }
}

返回?cái)?shù)據(jù)(String):

window.synccheck={retcode:"xxx",selector:"xxx"}

retcode:
    0 正常
    1100 失敗/登出微信
selector:
    0 正常
    2 新的消息
    7 進(jìn)入/離開(kāi)聊天界面

9. 獲取新消息(參考方法 webwxsync)

APIwebwxsync
urlwx2.qq.com/cgi-bin/mmwebwx-bin/webwxsync?sid=xxx&skey=xxx&pass_ticket=xxx
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8
params{
    BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
    SyncKey: xxx,
    rr:時(shí)間戳取反
}

返回?cái)?shù)據(jù)(JSON):

{
    'BaseResponse': {'ErrMsg': '', 'Ret': 0},
    'SyncKey': {
        'Count': 7,
        'List': [
            {'Val': 636214192, 'Key': 1},
            ...
        ]
    },
    'ContinueFlag': 0,
    'AddMsgCount': 1,
    'AddMsgList': [
        {
            'FromUserName': '',
            'PlayLength': 0,
            'RecommendInfo': {...},
            'Content': "", 
            'StatusNotifyUserName': '',
            'StatusNotifyCode': 5,
            'Status': 3,
            'VoiceLength': 0,
            'ToUserName': '',
            'ForwardFlag': 0,
            'AppMsgType': 0,
            'AppInfo': {'Type': 0, 'AppID': ''},
            'Url': '',
            'ImgStatus': 1,
            'MsgType': 51,
            'ImgHeight': 0,
            'MediaId': '', 
            'FileName': '',
            'FileSize': '',
            ...
        },
        ...
    ],
    'ModChatRoomMemberCount': 0,
    'ModContactList': [],
    'DelContactList': [],
    'ModChatRoomMemberList': [],
    'DelContactCount': 0,
    ...
}

10. 發(fā)送消息(參考方法 webwxsendmsg)

APIwebwxsendmsg
urlwx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsg?pass_ticket=xxx
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8
params{
    BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
    Msg: {
        Type: 1 文字消息,
        Content: 要發(fā)送的消息,
        FromUserName: 自己的ID,
        ToUserName: 好友的ID,
        LocalID: 與clientMsgId相同,
        ClientMsgId: 時(shí)間戳左移4位隨后補(bǔ)上4位隨機(jī)數(shù)
    }
}

返回?cái)?shù)據(jù)(JSON):

{
    "BaseResponse": {
        "Ret": 0,
        "ErrMsg": ""
    },
    ...
}

以上是“微信web協(xié)議的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!


名稱欄目:微信web協(xié)議的示例分析-創(chuàng)新互聯(lián)
路徑分享:http://weahome.cn/article/sheid.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部