Convert Figma logo to code with AI

Urinx logoWeixinBot

网页版微信API,包含终端版微信及微信机器人

7,208
1,980
7,208
200

Top Related Projects

13,948

微信机器人 / 可能是最优雅的微信个人号 API ✨✨

25,429

A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。

19,998

Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt

Mac微信功能拓展/微信插件/微信小助手(A plugin for Mac WeChat)

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT-o1/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。

Quick Overview

WeixinBot is a Python-based WeChat (Weixin) personal account API that allows users to automate interactions with WeChat. It provides functionality for logging in, sending messages, and managing contacts programmatically, enabling developers to create bots and automated scripts for WeChat.

Pros

  • Offers programmatic access to WeChat features without using the official API
  • Supports various WeChat functionalities like sending messages, managing contacts, and handling group chats
  • Written in Python, making it accessible to a wide range of developers
  • Includes a web-based interface for easier interaction and debugging

Cons

  • May violate WeChat's terms of service, potentially leading to account suspension
  • Relies on reverse-engineering WeChat's web interface, which could break with updates
  • Limited documentation and may require some technical expertise to use effectively
  • Not officially supported or endorsed by WeChat/Tencent

Code Examples

  1. Logging in to WeChat:
from wxbot import WXBot

bot = WXBot()
bot.run()
  1. Sending a message to a friend:
friend_username = 'example_username'
message = 'Hello from WeixinBot!'
bot.send_msg(friend_username, message)
  1. Handling incoming messages:
@bot.msg_register
def handle_msg(msg):
    if msg['msg_type_id'] == 4 and msg['content']['type'] == 0:
        bot.send_msg(msg['user']['id'], 'Thanks for your message!')

Getting Started

To get started with WeixinBot:

  1. Clone the repository:

    git clone https://github.com/Urinx/WeixinBot.git
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run the bot:

    from wxbot import WXBot
    
    bot = WXBot()
    bot.run()
    
  4. Scan the QR code with your WeChat mobile app to log in.

  5. Start interacting with WeChat programmatically using the bot object.

Competitor Comparisons

13,948

微信机器人 / 可能是最优雅的微信个人号 API ✨✨

Pros of wxpy

  • More actively maintained with recent updates
  • Comprehensive documentation and examples
  • Supports both WeChat Web and iPad protocols

Cons of wxpy

  • Requires Python 3.4+, while WeixinBot supports Python 2.7
  • May have a steeper learning curve for beginners
  • Less focused on specific bot functionality, more of a general-purpose library

Code Comparison

WeixinBot:

@bot.register(['Friend', 'Group'])
def reply_text(msg):
    return 'received: {} ({})'.format(msg.text, msg.type)

bot.join()

wxpy:

@bot.register()
def print_messages(msg):
    print(msg)

embed()

Both libraries use decorators for message handling, but wxpy's approach is more flexible and allows for easier customization. WeixinBot's code is more specific to replying to messages, while wxpy's example demonstrates a general message printing function.

25,429

A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。

Pros of ItChat

  • More actively maintained with regular updates
  • Better documentation and examples for easier implementation
  • Supports both personal and public WeChat accounts

Cons of ItChat

  • Slightly more complex setup process
  • May have slower performance for certain operations
  • Limited customization options compared to WeixinBot

Code Comparison

WeixinBot:

def get_uuid(self):
    url = 'https://login.weixin.qq.com/jslogin'
    params = {
        'appid': 'wx782c26e4c19acffb',
        'fun': 'new',
        'lang': 'zh_CN',
        '_': int(time.time()),
    }

ItChat:

def get_QRuuid(self):
    url = '%s/jslogin' % LOGIN_TEMPLATE
    params = {
        'appid': 'wx782c26e4c19acffb',
        'fun': 'new',
        'lang': 'zh_CN',
        '_': int(time.time() * 1000),
    }

Both repositories provide similar functionality for interacting with WeChat, but ItChat offers a more user-friendly experience with better documentation and support for different account types. WeixinBot, on the other hand, may offer more flexibility for advanced users who want to customize their implementation. The code comparison shows that both projects use similar approaches for obtaining the QR code UUID, with minor differences in URL structure and timestamp formatting.

19,998

Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt

Pros of Wechaty

  • Multi-platform support (Web, Pad, Mac, Windows, Linux)
  • Extensive documentation and active community
  • Supports multiple messaging protocols beyond just WeChat

Cons of Wechaty

  • More complex setup and configuration
  • Larger codebase and potentially steeper learning curve
  • May require more resources to run

Code Comparison

WeixinBot:

def get_uuid(self):
    url = 'https://login.weixin.qq.com/jslogin'
    params = {
        'appid': 'wx782c26e4c19acffb',
        'fun': 'new',
        'lang': 'zh_CN',
        '_': int(time.time()),
    }

Wechaty:

import { Wechaty } from 'wechaty'

const bot = new Wechaty()
bot.on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://wechaty.js.org/qrcode/${encodeURIComponent(qrcode)}`))
bot.on('login', user => console.log(`User ${user} logged in`))
bot.start()

WeixinBot is a Python-based WeChat bot focused specifically on WeChat, offering a simpler setup but with limited features. Wechaty, on the other hand, is a more comprehensive JavaScript/TypeScript solution that supports multiple platforms and messaging protocols, providing greater flexibility but requiring more setup and resources. Wechaty's extensive documentation and active community make it more suitable for complex projects, while WeixinBot might be preferable for simpler, WeChat-specific applications.

Mac微信功能拓展/微信插件/微信小助手(A plugin for Mac WeChat)

Pros of WeChatExtension-ForMac

  • More actively maintained with frequent updates
  • Specifically designed for macOS, offering better integration
  • Includes additional features like message recall prevention and auto-reply

Cons of WeChatExtension-ForMac

  • Limited to macOS platform, reducing cross-platform compatibility
  • Requires installation as a plugin, potentially more complex setup
  • May be affected by WeChat updates more frequently due to its nature as an extension

Code Comparison

WeixinBot (Python):

def send_msg_by_uid(self, word, dst='filehelper'):
    url = self.base_uri + '/webwxsendmsg?pass_ticket=%s' % self.pass_ticket
    msg_id = str(int(time.time() * 1000)) + str(random.random())[:5].replace('.', '')
    word = self.to_unicode(word)
    params = {
        'BaseRequest': self.base_request,
        'Msg': {
            "Type": 1,
            "Content": word,
            "FromUserName": self.my_account['UserName'],
            "ToUserName": dst,
            "LocalID": msg_id,
            "ClientMsgId": msg_id
        }
    }
    headers = {'content-type': 'application/json; charset=UTF-8'}
    data = json.dumps(params, ensure_ascii=False).encode('utf8')
    try:
        r = self.session.post(url, data=data, headers=headers)
    except (ConnectionError, ReadTimeout):
        return False
    dic = r.json()
    return dic['BaseResponse']['Ret'] == 0

WeChatExtension-ForMac (Objective-C):

- (void)sendTextMessage:(NSString *)text toUsrName:(NSString *)userName
{
    WeChat *wechat = [objc_getClass("WeChat") sharedInstance];
    MMServiceCenter *serviceCenter = [wechat serviceCenter];
    id msgService = [serviceCenter getService:objc_getClass("MMMessageService")];
    
    WCContactData *contact = [msgService getContact:userName];
    [msgService SendTextMessage:contact.m_nsUsrName toUsrName:contact.m_nsUsrName msgText:text atUserList:nil];
}

The code snippets show different approaches to sending messages, with WeixinBot using HTTP requests and WeChatExtension-ForMac utilizing WeChat's internal APIs.

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT-o1/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。

Pros of chatgpt-on-wechat

  • Integrates ChatGPT functionality directly into WeChat
  • Supports multiple AI models, including GPT-3.5-turbo and GPT-4
  • Offers more advanced features like image generation and voice message processing

Cons of chatgpt-on-wechat

  • Requires OpenAI API key, which may incur costs
  • More complex setup process due to additional dependencies
  • Potential privacy concerns with sending messages to external AI services

Code Comparison

WeixinBot:

def handle_msg(self, r):
    for msg in r['AddMsgList']:
        print('[*] New message from %s: %s' % (msg['FromUserName'], msg['Content']))

chatgpt-on-wechat:

async def handle_message(self, msg: Message):
    if msg.type == MessageType.TEXT:
        await self.handle_text_message(msg)
    elif msg.type == MessageType.VOICE:
        await self.handle_voice_message(msg)

The code comparison shows that chatgpt-on-wechat has more sophisticated message handling, supporting different message types and using async functions for better performance. WeixinBot, on the other hand, has a simpler approach to message handling.

While WeixinBot focuses on basic WeChat bot functionality, chatgpt-on-wechat extends this by integrating AI capabilities. However, this comes at the cost of increased complexity and potential privacy concerns. The choice between the two depends on the specific requirements of the project and the level of AI integration needed.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

WeixinBot star this repo fork this repo python

网页版微信API,包含终端版微信及微信机器人

Contents

Demo

为了确保能正常运行示例脚本,请安装所需的第三方包。

pip install -r requirements.txt

注:下面演示的图片与功能可能不是最新的,具体请看源码。

按照操作指示在手机微信上扫描二维码然后登录,你可以选择是否开启自动回复模式。

2

开启自动回复模式后,如果接收到的是文字消息就会自动回复,包括群消息。

3

名片,链接,动画表情和地址位置消息。

4

5

网页版上有的功能目前基本上都能支持。

Web Weixin Pipeline

       +--------------+     +---------------+   +---------------+
       |              |     |               |   |               |
       |   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|
+-------------+

Web Weixin API

登录

API获取 UUID
urlhttps://login.weixin.qq.com/jslogin
methodPOST
dataURL Encode
paramsappid: 应用ID
fun: new 应用类型
lang: zh_CN 语言
_: 时间戳

返回数据(String):

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

注:这里的appid就是在微信开放平台注册的应用的AppID。网页版微信有两个AppID,早期的是wx782c26e4c19acffb,在微信客户端上显示为应用名称为Web微信;现在用的是wxeb7ec651dd0aefa9,显示名称为微信网页版。


API绑定登陆(webwxpushloginurl)
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxpushloginurl
methodGET
paramsuin: xxx

返回数据(String):

{'msg': 'all ok', 'uuid': 'xxx', 'ret': '0'}

通过这种方式可以省掉扫二维码这步操作,更加方便

API生成二维码
urlhttps://login.weixin.qq.com/l/ uuid
methodGET

API二维码扫描登录
urlhttps://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login
methodGET
paramstip: 1 未扫描 0 已扫描
uuid: xxx
_: 时间戳

返回数据(String):

window.code=xxx;

xxx:
	408 登陆超时
	201 扫描成功
	200 确认登录

当返回200时,还会有
window.redirect_uri="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=xxx&uuid=xxx&lang=xxx&scan=xxx";

APIwebwxnewloginpage
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage
methodGET
paramsticket: xxx
uuid: xxx
lang: zh_CN 语言
scan: xxx
fun: new

返回数据(XML):

<error>
	<ret>0</ret>
	<message>OK</message>
	<skey>xxx</skey>
	<wxsid>xxx</wxsid>
	<wxuin>xxx</wxuin>
	<pass_ticket>xxx</pass_ticket>
	<isgrayscale>1</isgrayscale>
</error>

微信初始化

APIwebwxinit
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?pass_ticket=xxx&skey=xxx&r=xxx
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8
params{
     BaseRequest: {
         Uin: xxx,
         Sid: xxx,
         Skey: xxx,
         DeviceID: xxx,
     }
}

返回数据(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
}

APIwebwxstatusnotify
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify?lang=zh_CN&pass_ticket=xxx
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8
params{
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Code: 3,
     FromUserName: 自己ID,
     ToUserName: 自己ID,
     ClientMsgId: 时间戳
}

返回数据(JSON):

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

获取联系人信息

APIwebwxgetcontact
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin//webwxgetcontact?pass_ticket=xxx&skey=xxx&r=xxx
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8

返回数据(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": "你好,我们是地球三体组织。在这里,你将感受到不一样的思维模式,以及颠覆常规的世界观。而我们的目标,就是以三体人的智慧,引领人类未来科学技术500年。",
			"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
}

APIwebwxbatchgetcontact
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact?type=ex&r=xxx&pass_ticket=xxx
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8
params{
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Count: 群数量,
     List: [
         { UserName: 群ID, EncryChatRoomId: "" },
         ...
     ],
}

返回数据(JSON)同上

同步刷新

APIsynccheck
protocolhttps
hostwebpush.weixin.qq.com
webpush.wx2.qq.com
webpush.wx8.qq.com
webpush.wx.qq.com
webpush.web2.wechat.com
webpush.web.wechat.com
path/cgi-bin/mmwebwx-bin/synccheck
methodGET
dataURL Encode
paramsr: 时间戳
sid: xxx
uin: xxx
skey: xxx
deviceid: xxx
synckey: xxx
_: 时间戳

返回数据(String):

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

retcode:
	0 正常
	1100 失败/登出微信
selector:
	0 正常
	2 新的消息
	7 进入/离开聊天界面

APIwebwxsync
urlhttps://wx.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: 时间戳取反
}

返回数据(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,
	...
}

消息接口

APIwebwxsendmsg
urlhttps://wx.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: 要发送的消息,
         FromUserName: 自己ID,
         ToUserName: 好友ID,
         LocalID: 与clientMsgId相同,
         ClientMsgId: 时间戳左移4位随后补上4位随机数
     }
}

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	},
	...
}
APIwebwxrevokemsg
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxrevokemsg
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8
params{
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     SvrMsgId: msg_id,
     ToUserName: user_id,
     ClientMsgId: local_msg_id
}

返回数据(JSON):

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

发送表情

APIwebwxsendmsgemotion
urlhttps://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendemoticon?fun=sys&f=json&pass_ticket=xxx
methodPOST
dataJSON
headerContentType: application/json; charset=UTF-8
params{
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Msg: {
         Type: 47 emoji消息,
         EmojiFlag: 2,
         MediaId: 表情上传后的媒体ID,
         FromUserName: 自己ID,
         ToUserName: 好友ID,
         LocalID: 与clientMsgId相同,
         ClientMsgId: 时间戳左移4位随后补上4位随机数
     }
}

图片接口

APIwebwxgeticon
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgeticon
methodGET
paramsseq: 数字,可为空
username: ID
skey: xxx

APIwebwxgetheadimg
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetheadimg
methodGET
paramsseq: 数字,可为空
username: 群ID
skey: xxx

APIwebwxgetmsgimg
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetmsgimg
methodGET
paramsMsgID: 消息ID
type: slave 略缩图 or 为空时加载原图
skey: xxx

多媒体接口

APIwebwxgetvideo
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetvideo
methodGET
paramsmsgid: 消息ID
skey: xxx

APIwebwxgetvoice
urlhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetvoice
methodGET
paramsmsgid: 消息ID
skey: xxx

账号类型

类型说明
个人账号以@开头,例如:@xxx
群聊以@@开头,例如:@@xxx
公众号/服务号以@开头,但其VerifyFlag & 8 != 0

VerifyFlag:
         一般个人公众号/服务号:8
         一般企业的服务号:24
         微信官方账号微信团队:56
特殊账号像文件传输助手之类的账号,有特殊的ID,目前已知的有:
filehelper, newsapp, fmessage, weibo, qqmail, tmessage, qmessage, qqsync, floatbottle, lbsapp, shakeapp, medianote, qqfriend, readerapp, blogapp, facebookapp, masssendapp, meishiapp, feedsapp, voip, blogappweixin, weixin, brandsessionholder, weixinreminder, officialaccounts, notification_messages, wxitil, userexperience_alarm, notification_messages

消息类型

消息一般格式:

{
	"FromUserName": "",
	"ToUserName": "",
	"Content": "",
	"StatusNotifyUserName": "",
	"ImgWidth": 0,
	"PlayLength": 0,
	"RecommendInfo": {...},
	"StatusNotifyCode": 4,
	"NewMsgId": "",
	"Status": 3,
	"VoiceLength": 0,
	"ForwardFlag": 0,
	"AppMsgType": 0,
	"Ticket": "",
	"AppInfo": {...},
	"Url": "",
	"ImgStatus": 1,
	"MsgType": 1,
	"ImgHeight": 0,
	"MediaId": "",
	"MsgId": "",
	"FileName": "",
	"HasProductId": 0,
	"FileSize": "",
	"CreateTime": 1454602196,
	"SubMsgType": 0
}

MsgType说明
1文本消息
3图片消息
34语音消息
37好友确认消息
40POSSIBLEFRIEND_MSG
42共享名片
43视频消息
47动画表情
48位置消息
49分享链接
50VOIPMSG
51微信初始化消息
52VOIPNOTIFY
53VOIPINVITE
62小视频
9999SYSNOTICE
10000系统消息
10002撤回消息

微信初始化消息

MsgType: 51
FromUserName: 自己ID
ToUserName: 自己ID
StatusNotifyUserName: 最近联系的联系人ID
Content:
	<msg>
	    <op id='4'>
	        <username>
	        	// 最近联系的联系人
	            filehelper,xxx@chatroom,wxid_xxx,xxx,...
	        </username>
	        <unreadchatlist>
	            <chat>
	                <username>
	                	// 朋友圈
	                    MomentsUnreadMsgStatus
	                </username>
	                <lastreadtime>
	                    1454502365
	                </lastreadtime>
	            </chat>
	        </unreadchatlist>
	        <unreadfunctionlist>
	        	// 未读的功能账号消息,群发助手,漂流瓶等
	        </unreadfunctionlist>
	    </op>
	</msg>

文本消息

MsgType: 1
FromUserName: 发送方ID
ToUserName: 接收方ID
Content: 消息内容

图片消息

MsgType: 3
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取图片
Content:
	<msg>
		<img length="6503" hdlength="0" />
		<commenturl></commenturl>
	</msg>

小视频消息

MsgType: 62
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取小视频
Content:
	<msg>
		<img length="6503" hdlength="0" />
		<commenturl></commenturl>
	</msg>

地理位置消息

MsgType: 1
FromUserName: 发送方ID
ToUserName: 接收方ID
Content: http://weixin.qq.com/cgi-bin/redirectforward?args=xxx
// 属于文本消息,只不过内容是一个跳转到地图的链接

名片消息

MsgType: 42
FromUserName: 发送方ID
ToUserName: 接收方ID
Content:
	<?xml version="1.0"?>
	<msg bigheadimgurl="" smallheadimgurl="" username="" nickname=""  shortpy="" alias="" imagestatus="3" scene="17" province="" city="" sign="" sex="1" certflag="0" certinfo="" brandIconUrl="" brandHomeUrl="" brandSubscriptConfigUrl="" brandFlags="0" regionCode="" />

RecommendInfo:
	{
		"UserName": "xxx", // ID
		"Province": "xxx", 
		"City": "xxx", 
		"Scene": 17, 
		"QQNum": 0, 
		"Content": "", 
		"Alias": "xxx", // 微信号
		"OpCode": 0, 
		"Signature": "", 
		"Ticket": "", 
		"Sex": 0, // 1:男, 2:女
		"NickName": "xxx", // 昵称
		"AttrStatus": 4293221, 
		"VerifyFlag": 0
	}

语音消息

MsgType: 34
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取语音
Content:
	<msg>
		<voicemsg endflag="1" cancelflag="0" forwardflag="0" voiceformat="4" voicelength="1580" length="2026" bufid="216825389722501519" clientmsgid="49efec63a9774a65a932a4e5fcd4e923filehelper174_1454602489" fromusername="" />
	</msg>

动画表情

MsgType: 47
FromUserName: 发送方ID
ToUserName: 接收方ID
Content:
	<msg>
		<emoji fromusername = "" tousername = "" type="2" idbuffer="media:0_0" md5="e68363487d8f0519c4e1047de403b2e7" len = "86235" productid="com.tencent.xin.emoticon.bilibili" androidmd5="e68363487d8f0519c4e1047de403b2e7" androidlen="86235" s60v3md5 = "e68363487d8f0519c4e1047de403b2e7" s60v3len="86235" s60v5md5 = "e68363487d8f0519c4e1047de403b2e7" s60v5len="86235" cdnurl = "http://emoji.qpic.cn/wx_emoji/eFygWtxcoMF8M0oCCsksMA0gplXAFQNpiaqsmOicbXl1OC4Tyx18SGsQ/" designerid = "" thumburl = "http://mmbiz.qpic.cn/mmemoticon/dx4Y70y9XctRJf6tKsy7FwWosxd4DAtItSfhKS0Czr56A70p8U5O8g/0" encrypturl = "http://emoji.qpic.cn/wx_emoji/UyYVK8GMlq5VnJ56a4GkKHAiaC266Y0me0KtW6JN2FAZcXiaFKccRevA/" aeskey= "a911cc2ec96ddb781b5ca85d24143642" ></emoji> 
		<gameext type="0" content="0" ></gameext>
	</msg>

普通链接或应用分享消息

MsgType: 49
AppMsgType: 5
FromUserName: 发送方ID
ToUserName: 接收方ID
Url: 链接地址
FileName: 链接标题
Content:
	<msg>
		<appmsg appid=""  sdkver="0">
			<title></title>
			<des></des>
			<type>5</type>
			<content></content>
			<url></url>
			<thumburl></thumburl>
			...
		</appmsg>
		<appinfo>
			<version></version>
			<appname></appname>
		</appinfo>
	</msg>

音乐链接消息

MsgType: 49
AppMsgType: 3
FromUserName: 发送方ID
ToUserName: 接收方ID
Url: 链接地址
FileName: 音乐名

AppInfo: // 分享链接的应用
	{
		Type: 0, 
		AppID: wx485a97c844086dc9
	}

Content:
	<msg>
		<appmsg appid="wx485a97c844086dc9"  sdkver="0">
			<title></title>
			<des></des>
			<action></action>
			<type>3</type>
			<showtype>0</showtype>
			<mediatagname></mediatagname>
			<messageext></messageext>
			<messageaction></messageaction>
			<content></content>
			<contentattr>0</contentattr>
			<url></url>
			<lowurl></lowurl>
			<dataurl>
				http://ws.stream.qqmusic.qq.com/C100003i9hMt1bgui0.m4a?vkey=6867EF99F3684&amp;guid=ffffffffc104ea2964a111cf3ff3edaf&amp;fromtag=46
			</dataurl>
			<lowdataurl>
				http://ws.stream.qqmusic.qq.com/C100003i9hMt1bgui0.m4a?vkey=6867EF99F3684&amp;guid=ffffffffc104ea2964a111cf3ff3edaf&amp;fromtag=46
			</lowdataurl>
			<appattach>
				<totallen>0</totallen>
				<attachid></attachid>
				<emoticonmd5></emoticonmd5>
				<fileext></fileext>
			</appattach>
			<extinfo></extinfo>
			<sourceusername></sourceusername>
			<sourcedisplayname></sourcedisplayname>
			<commenturl></commenturl>
			<thumburl>
				http://imgcache.qq.com/music/photo/album/63/180_albumpic_143163_0.jpg
			</thumburl>
			<md5></md5>
		</appmsg>
		<fromusername></fromusername>
		<scene>0</scene>
		<appinfo>
			<version>29</version>
			<appname>摇一摇搜歌</appname>
		</appinfo>
		<commenturl></commenturl>
	</msg>

群消息

MsgType: 1
FromUserName: @@xxx
ToUserName: @xxx
Content:
	@xxx:<br/>xxx

红包消息

MsgType: 49
AppMsgType: 2001
FromUserName: 发送方ID
ToUserName: 接收方ID
Content: 未知

注:根据网页版的代码可以看到未来可能支持查看红包消息,但目前走的是系统消息,见下。

系统消息

MsgType: 10000
FromUserName: 发送方ID
ToUserName: 自己ID
Content:
	"你已添加了 xxx ,现在可以开始聊天了。"
	"如果陌生人主动添加你为朋友,请谨慎核实对方身份。"
	"收到红包,请在手机上查看"

Discussion Group

如果你希望和 WeixinBot 的其他开发者交流,或者有什么问题和建议,欢迎大家加入微信群【Youth fed the dog】一起讨论。扫描下面的二维码添加机器人为好友,并回复【Aidog】获取入群链接。

join us

注:这个不是群的二维码,是机器人拉你入群,记得回复机器人【Aidog】哦~ (secret code: Aidog)

Recent Update

  • association_login 目前网页版微信已经可以脱离扫码,但是依然需要在客户端进行确认登录。