I wrote a short program, the code is as follows:
var config = require("./mcConfig.js");
var request = require("request");
function sendWCMeaasge(content, callback){
var postData = {
location:"v6_content_home".text: content,
style_type:"1".isReEdit:false.module:"stissue".pub_source:"main_".pub_type:"dialog".isPri:0._t:0
};
var options = {
url: "https://www.weibo.com/aj/mblog/add?ajwvr=6&__rnd=1564468131832".method: "POST".headers: {
"cookie": config.cookie,
"origin": "https://www.weibo.com"."referer": "https://www.weibo.com/abap/home?wvr=5"."content-type": "application/x-www-form-urlencoded"
},
form: postData
};
request(options,function(error,response,data){
// console.log(data);
if(!!!!! data){var oResponse = JSON.parse(data); callback(oResponse.code); }}); }module.exports = sendWCMeaasge;
Copy the code
Use this simple code to consume the send function:
var tool = require("./SendWeiboModule.js");
var config = require("./mcConfig.js");
tool("i042416".function(code){
console.log("response from Weibo: " + code);
});
Copy the code
Execute the nodejs application using the command line:
Send a tweet with the content i042416:You’ll see this post on your browser soon:
For more of Jerry’s original articles, please follow the public account “Wang Zixi “: