-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.ahk
71 lines (54 loc) · 1.47 KB
/
example.ahk
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
71
#Include %A_ScriptDir%\lib\JXON.ahk
#Include %A_ScriptDir%\lib\ahk_requests.ahk
;grab python executable here https://github.com/samfisherirl/ahk_requests.py
;praise and credit to: https://github.com/TheArkive/JXON_ahk2
; Simple
url := "https://httpbin.org/get"
; see bottom for additional params
req := requests(url)
req.get()
msgbox(req.jdata["origin"])
msgbox(req.txt)
/*
**************************************************************
*/
; Intermediate example
url := "https://httpbin.org/get"
headers := Map("key1", "value1")
params := Map("key1", "value1")
req := requests(url, headers, params)
req.get()
msgbox(req.jdata["origin"])
msgbox(req.txt)
/*
**************************************************************
*/
; Complex example Airtable API
; https://github.com/josephbestjames/airtable.py
api_key := "xxxxx"
base_id := "yyyyy"
table_name := "zzzzzz"
url := "https://api.airtable.com/v0/" . base_id . "/" . table_name
headers := Map(
"Authorization",
"Bearer " . api_key
)
; headers := False => gets converted to {"User-Agent":"Mozilla/5.0 (Macintosh;...
params := Map("view", "Grid view")
req := requests(url, headers, params)
req.allowRedirect := True ;optional
req.stream := False ;optional
req.get()
msg := ""
for k, v in req.jdata
{
;json data
try {
msg .= k . ": " . v . "`n"
}
catch {
continue
}
}
msgbox(msg)
msgbox(req.txt)