Send HTTP request
Get page on example.com​
1
HTTP.get( {
2
url: "http://example.com",
3
success: '/onLoading',
4
error: '/onError'
5
6
// if you need pass headers.
7
// By default header "content-type" = 'application/json'
8
// headers: { "content-type": null }
9
// folow_redirects: true, // if you need folow by redirects
10
// background: true - if you have timeout error
11
} )
12
​
13
/* also you can send POST request
14
HTTP.post( {
15
url: "http://example.com",
16
success: '/onLoading ',
17
body: {}, // body params
18
// cookies: "" // cookies
19
// headers: { "content-type": null } // - if you need headers
20
// folow_redirects: true, // if you need folow by redirects
21
} )
22
*/
Copied!
By default header "content-type" is 'application/json'. Some api may have a bug with this. Try set headers: { "content-type": null }
Command onLoading
1
// downloaded page stored on content field
2
Bot.sendMessage(content);
3
​
4
Bot.inspect(http_status); // "200"
5
Bot.inspect(http_headers); // headers from response
6
Bot.inspect(cookies); // it is blank for example.com
Copied!
Command onError
1
Bot.sendMessage("Error on downloading");
2
​
3
Bot.inspect(http_status);
4
Bot.inspect(http_headers); // headers from response
5
Bot.inspect(cookies);
Copied!
Http request can be performed in background with bigger timeout.
Pass background: true if you need request from slow web page. Task on backgroud is more slowly but it have bigger timeout limit.
​
Last modified 1yr ago
Copy link