-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
57 lines (52 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var axios = require("axios");
var fd = require("form-data");
var fs = require("fs");
module.exports = class Mewe {
constructor() {
this.root = 'https://mewe.com/api/v2';
}
addToken(token) {
this.token = token;
}
async getProfile() {
var profile = await axios({
url: this.root + '/me/info',
headers: {
authorization: 'Sgrouples accessToken= ' + this.token
}
});
return profile.data;
}
async post(text,img_id) {
var res = await axios({
url: this.root + '/home/post',
method: 'POST',
data: {
"text": text,
"imageIds": img_id?[img_id]:[],
"existingFileIds": [],
"mediaIds": [],
"public": true,
"closeFriends": false
},
headers: {
authorization: 'Sgrouples accessToken= ' + this.token
}
});
return res.data;
}
async upload(path) {
var data = new fd();
data.append("file",fs.createReadStream(path));
var id = await axios({
url: this.root + '/photo/pt',
method: 'POST',
data: data,
headers: {
authorization: 'Sgrouples accessToken= ' + this.token,
...data.getHeaders()
}
});
return id.data.id;
}
}