Created
June 3, 2014 04:45
-
-
Save Abundnce10/bd64f8a235829cab5318 to your computer and use it in GitHub Desktop.
Run this script on OnCue.io to get today's weather for Seattle
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
| // require modules | |
| var request = require('request'); | |
| var services = require('#services'); | |
| // other variables | |
| var phoneNumber = '+1XXXXXXXXX'; | |
| var city = 'Seattle'; | |
| // Ultimate Weather API credentials | |
| var options = { | |
| url: 'https://george-vustrey-weather.p.mashape.com/api.php?location=' + city, | |
| headers: { | |
| "X-Mashape-Authorization": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
| } | |
| }; | |
| // Parse Response | |
| function callback(error, response, body) { | |
| if (!error && response.statusCode == 200) { | |
| // Parse today's weather forecast | |
| var today = JSON.parse(body)[0]; | |
| var forecast = "High of " + today.high + ", Low of " + today.low + ". " + today.condition; | |
| // Send text message | |
| services.sms.send({ | |
| to : phoneNumber, | |
| body : forecast | |
| } , process.exit); | |
| } | |
| } | |
| // Hit API | |
| request(options, callback); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add your Mashape credentials and phone number. Run on https://oncue.io/