Last active
May 12, 2019 12:00
-
-
Save VerizonMediaOwner/40e8edccaab25e2b3b5001d2ecc1d070 to your computer and use it in GitHub Desktop.
Yahoo Weather API JavaScript Example
This file contains 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
// Require node-oauth package: npm install oauth | |
// Copyright 2019 Oath Inc. Licensed under the terms of the zLib license see https://opensource.org/licenses/Zlib for terms. | |
var OAuth = require('oauth'); | |
var header = { | |
"X-Yahoo-App-Id": "your-app-id" | |
}; | |
var request = new OAuth.OAuth( | |
null, | |
null, | |
'your-consumer-key', | |
'your-consumer-secret', | |
'1.0', | |
null, | |
'HMAC-SHA1', | |
null, | |
header | |
); | |
request.get( | |
'https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale,ca&format=json', | |
null, | |
null, | |
function (err, data, result) { | |
if (err) { | |
console.log(err); | |
} else { | |
console.log(data) | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
call the function outside request.get
create a global variable to parse the json data