This repository has been archived by the owner on Feb 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathexamples.js
70 lines (60 loc) · 1.79 KB
/
examples.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
58
59
60
61
62
63
64
65
66
67
68
69
70
const { buildAccountCreator } = require('../index')
const twoCaptchaApiKey = 'YOUR_TWO_CAPTCHA_API_KEY'
const accountCreator = buildAccountCreator(twoCaptchaApiKey)
/**
* Creates an account by generating a random email/password and birthday.
*/
function withRandomCredentials () {
accountCreator.register().then(({ credentials, birthday }) => {
console.log(`We registered ${credentials.email} with ${credentials.password}. Birthday: ${birthday}`)
}).catch(error => {
console.log(error)
})
}
// Uncomment the line below to run the example
// withRandomCredentials()
/**
* Creates an account using the specified email/password and generating a birthday.
*/
function withSpecifiedCredentials () {
accountCreator.register({
email: '[email protected]',
password: 'examplepassword'
}).then(response => {
console.log(response)
}).catch(error => {
console.log(error)
})
}
// withSpecifiedCredentials()
/**
* Creates an account using the specified email/password/birthday,
* and the specified socks5 proxy.
*/
function withProxy () {
accountCreator.register({
// email: '[email protected]',
password: 'examplepassword',
proxy: 'socks5://username:[email protected]:1080'
}).then(response => {
console.log(response)
}).catch(error => {
console.log(error)
})
}
// withProxy()
/**
* Big fan of async/await? We've got you covered!
*/
async function example1 () {
try {
const { credentials, birthday } = await accountCreator.register({
// email: '[email protected]',
password: 'pass43594word'
})
console.log(`We registered an account! creds=(${credentials}) bday=${birthday.toLocaleString()}`)
} catch (e) {
console.error('Something went wrong with our registration attempt!', e)
}
}
//(async () => { await example1() })()