Skip to content

Instantly share code, notes, and snippets.

@ITJesse
Created April 2, 2018 09:12
Show Gist options
  • Save ITJesse/1277572980a820531b0e6d07ef9a2cb0 to your computer and use it in GitHub Desktop.
Save ITJesse/1277572980a820531b0e6d07ef9a2cb0 to your computer and use it in GitHub Desktop.
Wechat Bot API

登陆接口

Request

{
	"username": "test",
	"password": "test
}

Response

{
	"code": 200,
	"token": "xxxxxxxxxx",
	"expire": 3600
}

Code

  • 200: ok
  • -1: invaild input
  • -2: mismatch username or password
  • -999: server error

回报接口(心跳包):

客户端每 5s 回报一次,其中包含:

Request(待定)

{
	"id": 123,
	"body": [
		{
			"botId": 1,
			"type": "newmessage",
			"message": "test message"
		},
		{
			"botId": 1,
			"type": "newcontact",
			"wxid": "testid",
			"name": "testuser",
			"message": "test message"
		}
	]
}

Response

{
	"code": 200,
	"online":  [
		1, 2, 3
	],
	"offline": [
		4, 5, 6
	],
	"body":  [
		{
			"botId": 1,
			"type": "sendmessage",
			"toWxId": "testId",
			"message": "test message"
		},
		{
			"botId": 1,
			"type": "newcontact",
			"wxId": "testId",
			"accept": true
		}
	]
}

添加Bot

添加新的机器人账号

Request

{
	"wxId": "testId",
	"name": "testaccount",
	"info": "the first wechat bot"
}

Response

{
	"code": 200,
	"botId": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment