This is the implementation I use for curl:
$curl:"request" this none this
1: {options} = args;
2: o = options:merge(["method" -> "GET", "url" -> ""]);
3: o = (["method" -> "GET", "url" -> "", "data" -> [], "format" -> ""]):merge(options);
4: if (o["method"] == "GET")
5: methodString = " -G";
6: else
7: methodString = tostr(" -X ", o["method"]);
8: endif
9: dataString = "";
10: for value, key in (o["data"])
11: dataString = tostr(dataString, " -d ", key, "=", value, "");
12: endfor
13: cmd = tostr("curl -s", methodString, dataString, " ", o["url"]);
14: value = exec(cmd:split());
15: if (value[1] == 0)
16: if (o["format"] == "json")
17: value[2] = strsub(value[2], "~0A", "");
18: value[2] = strsub(value[2], "~09", "");
19: return parse_json(value[2]);
20: else
21: return value[2]:split("~0A");
22: endif
23: endif
And here is an example of how it is used, this verb queries the Steam API:
#697:"GetPlayerSummary" this none this
1: {id} = args;
2: idstr = "";
3: if (typeof(id) == LIST)
4: for x, k in (id)
5: if (k != 1)
6: idstr = tostr(idstr, ",", x);
7: else
8: idstr = tostr(x);
9: endif
10: endfor
11: else
12: idstr = id;
13: endif
14: req = $curl:request(["data" -> ["key" -> this.apikey, "steamids" -> idstr], "method" -> "GET", "format" -> "json", "url" -> "
http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/"]);
15: return req;