-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetFriendQR.js
45 lines (40 loc) · 1.16 KB
/
getFriendQR.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
const https = require('https');
module.exports = (user, cb) => {
const req = https.request({
method: 'POST',
hostname: 'api.qr-code-generator.com',
path: '/v1/create?access-token=EBephxedmZHs9OWzR2Kbv-125ifulLI1LemyW4NO2hwWifAzpHadEVcOq-OkFtNz',
headers: {
'Content-Type': 'application/json',
},
}, (res) => {
const chunks = [];
res.on('data', (chunk) => {
chunks.push(chunk);
});
res.on('end', () => {
cb(
Buffer.concat(chunks)
.toString()
.replace(
/( xml(.*?)"(.*?)")|( version(.*?)"(.*?)")|( id(.*?)"(.*?)")|( fill(.*?)"(.*?)")/g,
'',
)
.replace(/<r.*?>/i, ''),
);
});
res.on('error', (error) => {
console.error(error);
});
});
req.end(JSON.stringify({
qr_code_text: `http://pronotif.fr/addFriend/${user}`,
image_format: 'SVG',
background_color: '#000000',
marker_left_template: 'version11',
marker_right_template: 'version11',
marker_bottom_template: 'version11',
qr_code_logo: 'account11314567/logo/fd443fa78e05315d104d5e30674baa20.png',
qr_code_pattern: 'connect-horizontal',
}));
};