WeChat public platform simulation login automatic mass text message toolkit

The WeChat official account can automatically send pictures and text messages in groups without WeChat authentication.

use

npm i wechat-mp-hack --save
const Wechat = require('wechat-mp-hack');
const API = new Wechat('Official account number', 'Official account password');

 

After version 1.1.0, it is no longer necessary to wrap the calling method in the login callback to execute, and the login will be automatically processed when the following core methods are called.

events

scan.login

Login authentication QR code

API.once('scan.login', (filepath) => {
// Login QR code image address
console.log(filepath);
});

 

scan.send

After the group sending authentication protection is enabled, you need to scan the QR code on WeChat to call the group sending interface.

API.on('scan.send', (filepath) => {
// Mass send authentication QR code address
console.log(filepath);
});

 

vcode

Login verification code

API.once('vcode', (filepath) => {
// Verification code image address
console.log(filepath);
});

 

methods

login

login interface

/**
* @desc log in to the official account
* @param {string} [imgcode] - [optional] verification code
* [url=home.php?mod=space&uid=67594]@Return[/url] {Promise<object>} data
*/
API.login().then(data => {
console.log(data);
}).catch(console.error.bind(console));

  

loginchk

Check if you are logged in

try {
let islogin = await API.loginchk();
console.log('logged in');
} catch(e) {
console.log('Not logged in');
}

  

appmsg

Get a list of graphic/video materials

/**
* Get graphic/video material list
* @param {number} [type] - message type: text message-10 video message-15 default-10
* @param {number} [begin] - default -0 from which to start
* @param {number} [count] - return the default number of items -10
* @return {Promise<array>} - list of materials
* @return {number} [].app_id - 素材id appMsgId
* @return {string}[].author - the author
* @return {string} [].create_time - creation time in seconds
* @return {number} [].data_seq
* @return {string} [].digest - asset description information
* @return {number} [].file_id
* @return {string} [].img_url - image URL
* @return {number} [].is_illegal
* @return {number} [].is_sync_top_stories
* @return {array}[].multi_item - list of assets (multiple articles under one item)
* @return {string}[].multi_item[].author - the article author
* @return {string} [].multi_item[].author_appid
* @return {number} [].multi_item[].can_reward - whether the article can be rewarded, 0 no
* @return {string}[].multi_item[].cdn_url - image/video URL
* @return {string} [].multi_item[].cdn_url_back
* @return {number} [].multi_item[].cover - cover image address
* @return {string}[].multi_item[].digest - article description
* @return {number} [].multi_item[].file_id
* @return {string} [].multi_item[].free_content
* @return {number} [].multi_item[].is_new_video
* @return {number} [].multi_item[].need_open_comment
* @return {boolean} [].multi_item[].only_fans_can_comment
* @return {string} [].multi_item[].ori_white_list
* @return {number} [].multi_item[].review_status
* @return {number} [].multi_item[].reward_money
* @return {string} [].multi_item[].reward_wording
* @return {number} [].multi_item[].seq
* @return {number} [].multi_item[].show_cover_pic
* @return {number} [].multi_item[].smart_product
* @return {string} [].multi_item[].source_url - original address
* @return {string}[].multi_item[].title - article title
* @return {array<string>}[].multi_item[].tags - article tags
*/
API.appmsg().then((items) => {
console.log(items);
}).catch(console.error.bind(console));

  

filepage

Get picture/voice material list

/**
* Get picture/voice material list
* @param {number} [type] - material type: picture material-2 voice material-3 default-2
* @param {number} [begin] - default -0 from which to start
* @param {number} [count] - return the default number of items -10
* @param {number} [group_id] - only for picture material, group id all pictures-0 ungrouped-1 article picture-3 or other group id created by yourself
* @return {Promise<array>} - list of materials
* @return {string} [].cdn_url - resource URL
* @return {number} [].file_id
* @return {number} [].group_id - group id
* @return {string}[].img_format - image type: png...
* @return {string} [].name - resource name, eg: 1488631877698.png
* @return {number} [].seq
* @return {string}[].size - resource size, eg: 749.4 K
* @return {number} [].type
* @return {number} [].update_time - unit: seconds
* @return {string} [].video_cdn_id
* @return {string} [].video_thumb_cdn_url
*/
API.filepage().then((files) => {
console.log(files);
}).catch(console.error.bind(console));

  

operate_appmsg

Create graphic material

/**
* Create graphic materials
* @param {array} news - list of news
* @param {string} news[].title - article title
* @param {string} news[].thumb - the article thumbnail
* @param {string} news[].description - description information
* @param {string} news[].html - article content
* @param {string} news[].url - original address
* @param {number} [appMsgId] - id of graphic material, pass this field to update graphic material
* @return {Promise} appMsgId
*/
API.operate_appmsg(news).then((appMsgId) => {
console.log(appMsgId);
}).catch(console.error.bind(console));

  

batchUpload

Batch upload remote pictures to the official account

/**
* Batch upload remote pictures to the public account
* @param {array<string>} imgurls - remote image address
*/
API.batchUpload(['http://wesbos.com/wp-content/uploads/2016/09/dead-zone.png']).then((results) => {
// results[0].fileid;
// results[0].cdn_url;
});

 

filetransfer

Upload a single remote image to the official account

/**
* Upload a single remote picture to the official account
* @param {string} imgurl - remote image URL
*/
API.filetransfer('http://wesbos.com/wp-content/uploads/2016/09/dead-zone.png').then((result) => {
console.log(result);
});

 

localUpload

Upload local pictures to the public account

/**
* Upload local pictures to the public account
* @param {string} filepath - local image address
* @return {Promise<object>} res
* @return {number} res.fileid - resource id
* @return {string} res.cdn_url - resource link URL
*/
API.localUpload('qrcode-safe.png').then((result) => {
console.log(result);
});

 

uploadimg2cdn

Upload remote images to cdn

/**
* Upload remote pictures to cdn
* @param {string} imgurl - remote image URL
* @return {Promise<string>} - WeChat cdn resource address
*/

preview_post

Get a temporary preview link for a graphic material article

/**
* Get a temporary preview link for graphic material articles
* @param {number} appmsgid - image id
* @param {number} [itemidx] - the index of the article in the graphic material, starting from 1 Default: 1
* @return {Promise<string>} - link to temporary preview of article
*/
API.preview_post(100000126, 2).then(post_url => {
console.log(post_url);
}).catch(console.error.bind(console));

 

preview_appmsg

Preview mass message

/**
* Preview group messages
* @param {string} username - the previewer's WeChat account/QQ number/mobile phone number
* @param {number|string} content - preview content, graphic message-appmsgid text-content image/voice/video-fileid
* @param {number} [type] - message type: text message-10 text-1 picture-2 voice-3 video-15 default-10
*/
API.preview_appmsg('Zaker-yhz', 100000126).then(res => {
console.log('Preview sent successfully');
}).catch(console.error.bind(console));

 

masssend

group message

/**
* group message
* @param {number|string} appmsgid - message content, graphic message-appmsgid text-text content image/voice/video-fileid
* @param {number} [groupid] - group id, default -1 for all users
* @param {number} [send_time] - Scheduled group sending, default -0 Unscheduled group sending Scheduled group sending set time stamp (in seconds)
* @param {number} [type] - message type: text message-10 text-1 picture-2 voice-3 video-15 default-10
*/
API.masssend(appMsgId).then(() => {
console.log('success');
}).catch(console.error.bind(console));

  

cancel_time_send

Cancel scheduled broadcast

/**
* Cancel scheduled broadcast
* @param {number} msgid group message id
*/
API.cancel_time_send(1000000041).then(() => {
console.log('success');
}).catch(console.error.bind(console));

 

timesend_list

Scheduled group message list

/**
* Scheduled group message list
* @return {Promise<array>} msgs - list of scheduled group messages
* @return {number} msgs[].type - message type
* @return {number} msgs[].msgid - message id
* @return {object} msgs[].sent_info
* @return {number} msgs[].sent_info.time - broadcast time
* @return {boolean} msgs[].sent_info.is_send_all - whether to send to everyone
* @return {array} msgs[].appmsg_info - text message content
* @return {object} msgs[].text_info - text message
* @return {string} msgs[].text_info.content - text message content
*/
API.timesend_list().then(msgs => {
console.log(msgs);
});

 

singlesend

Send a text message to a user

/**
* Send a text message to a user
* @param {string} tofakeid - user fakeid, which can be seen in the url of the singlesendpage page in the background of the official account or the list of messages
* @param {string} msg - message content
* @param {string} [replyId] - reply message id, which can be seen in the message list, optional
*/
API.singlesend('osl8HwPBTCsVbquNsnYbUfOQH8sM', 'Hahahaha', 425131038).then(res => {
console.log(res);
}).catch(console.error.bind(console));

 

message

Get a list of official account messages

/**
* Get the list of public account messages
* @param {number} count - the number of messages
* @param {number|string} [day] - Today: 0 Yesterday: 1 The day before: 2 Earlier: 3 Last 5 days: 7 Favorites: star, default: 0
* @return {array<object>} msgs
* @return {string} msgs[].content - message content
* @return {string} msgs[].date_time - message time
* @return {string} msgs[].fakeid - 用户fakeid
* @return {number} msgs[].func_flag
* @return {number} msgs[].has_reply
* @return {number} msgs[].id - replyId
* @return {number} msgs[].is_vip_msg
* @return {number} msgs[].msg_status
* @return {array} msgs[].multi_item
* @return {string} msgs[].nick_name
* @return {string} msgs[].refuse_reason
* @return {string} msgs[].source
* @return {string} msgs[].to_uin
* @return {number} msgs[].type
* @return {string} msgs[].wx_headimg_url - URL of the user headimg
*/
API.message(1).then(msgs => {
console.log(msgs);
}).catch(console.error.bind(console));

  

user_list

Get the list of users who follow the official account

/**
* @desc get the list of followers
* @return {array<object>} userlist
* @return {string} userlist[].user_openid
* @return {string} userlist[].user_name - User nickname
* @return {string} userlist[].user_remark - User remark name
* @return {array} userlist[].user_group_id - 分组
* @return {number} userlist[].user_create_time - Follow time, unit: seconds
* @return {string} userlist[].user_head_img - user head address
*/
API.user_list().then(res => {
console.log(res);
});

  

user_info

Get a user's information

/**
* Get user information
* @param {string} user_openid
* @return {object} user
* @return {string} user.user_openid
* @return {string} user.user_name - User nickname
* @return {string} user.user_remark - user remark name
* @return {array} user.user_group_id - 分组
* @return {number} user.user_create_time - Follow time, unit: seconds
* @return {string} user.user_head_img - user head address
*/
API.user_info('oslHwqwYnw20jnqMca18KET91pa0').then(res => {
console.log(res);
});

  

user_info_detail

Get a user's details

/**
* Get user details
* @param {string} user_openid
* @return {object} user
* @return {string} user.user_openid
* @return {string} user.user_city - user city
* @return {string} user.user_country - user country
* @return {string} user.user_province - 省份
* @return {string} user.user_signature - 签名
* @return {number} user.user_comment_cnt - the number of comments
* @return {number} user.user_selected_comment_cnt - the number of selected comments
* @return {number} user.user_msg_cnt - message volume
* @return {number} user.user_gender - gender 0: unknown 1: male 2: female
* @return {string} user.user_name - User nickname
* @return {string} user.user_remark - user remark name
* @return {array} user.user_group_id - 分组
* @return {number} user.user_create_time - Follow time, unit: seconds
* @return {string} user.user_head_img - user head address
* @return {number} user.user_in_blacklist - is on the blacklist
*/
API.user_info_detail('oslHwqwYnw20jnqMca18KET91pa0').then(res => {
console.log(res);
});

  

qrdecode

QR code analysis

/**
* QR code analysis
* @param {string} url - remote image address/local image path
* @return {Promise<object>}
*/
API.qrdecode('qrcode-login.png').then((result) => {
console.log(result.text);
}).catch(console.error.bind(console));

 

Toolkit download address: Wechat public platform simulates login to automatically send graphic messages to the public. Download the toolkit

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324924366&siteId=291194637