Created
October 28, 2016 15:51
-
-
Save gjyoung1974/1bc2343ac9793fc7044e8284dfc68b7d to your computer and use it in GitHub Desktop.
JSON Post on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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