wechat-webclient
v0.1.2
Published
wechat webclient as a node.js module
Downloads
47
Readme
WeChat Node Client
Description:
This is a wechat client for node. It authenticates and acts as though the user is using the official wechat web interface.
Note: Development is continuing.
Installation:
npm install --save wechat-webclient
API Flow:
- Get uuid from WeChat service.
- Get QR code from WeChat service using uuid.
- Display QR code to user, so that they can scan it using their WeChat phone app
- User scans QR code, and confirms they'd like to login.
- Get the login data (cookies, postdata) from the WeChat service so it knows who we are.
- Get contact list, contact's icons
- Recieve messages as they come in, send messages and logout at will.
Usage:
var wechat = require('wechat-webclient');
var client = new wechat.weChatClient();
client.getUUID() // Gets uuid, passes to next function
.then(client.checkForScan.bind(client), errorhandlingfunction) // resolves when QR scan confirmed with the login url
.then(client.webwxnewloginpage.bind(client), errorhandlingfunction) // gets passed login url, resolves with login data
.then(client.webwxinit.bind(client), errorhandlingfunction) // initializes data for the user, (e.g. who this user is, auth data)
.then(function(whatever) { // whatever will be a JSON object containing login data.
return new Promise(function (resolve, reject) {
client.webwxgetcontact.bind(client, whatever);
// client.contacts is now populated.
// Do something with contacts
// eventually, resolve with what I've here called "whatever", because it is
// required for subsequent functions, or save it as a variable in a wide enough scope
// so that it can be utilized.
});
}, errorhandlingfunction)
.then(function(passedLoginData) {
//start some type of user interface here:
userInterfaceFunction();
return client.synccheck(passedLoginData); // passes back (actually nothing) stuff when it can no longer synccheck (e.g. logged out)
}.bind(client), errorhandlingfunction);
.then(handleProgramShutDownFunction, errorhandlingfunction);