Skip to content

Instantly share code, notes, and snippets.

@Abundnce10
Created June 3, 2014 04:45
Show Gist options
  • Select an option

  • Save Abundnce10/bd64f8a235829cab5318 to your computer and use it in GitHub Desktop.

Select an option

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
// 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);
@Abundnce10
Copy link
Copy Markdown
Author

Add your Mashape credentials and phone number. Run on https://oncue.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment