Skip to content

Instantly share code, notes, and snippets.

@gjyoung1974
Created October 28, 2016 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjyoung1974/1bc2343ac9793fc7044e8284dfc68b7d to your computer and use it in GitHub Desktop.
Save gjyoung1974/1bc2343ac9793fc7044e8284dfc68b7d to your computer and use it in GitHub Desktop.
JSON Post on Windows
//get a web resource: REST Api Post
var apiKey = '939f36408065e19b83f5f8352573257e';
function c3rl() {
try {
var xhr = new ActiveXObject("MSXML2.ServerXMLHTTP.6.0");
xhr.open("POST", 'http://api.openweathermap.org/data/2.5/weather?lat=33.265019&lon=-111.839103&appid=' + apiKey, false);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Accept', 'application/json');
xhr.send();
var doc = xhr.responseText
alert(doc);
}
catch (e) {
alert(e.description);
}
}
function alert(s) {
WScript.Echo(s);
}
WScript.Echo('get current weather as a JSON Array\n');
c3rl();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment