Skip to content

Instantly share code, notes, and snippets.

@jonleung
Created May 23, 2015 06:37
Show Gist options
  • Save jonleung/5605d90f71b7d094ed42 to your computer and use it in GitHub Desktop.
Save jonleung/5605d90f71b7d094ed42 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
var TwilioApp = React.createClass({
onChange: function(e) {
this.setState({text: e.target.value});
},
handleSubmit: function(e) {
e.preventDefault();
var text = e.input.getText();
Twilio.sendSms("610-761-0083", text);
alert("sent SMS");
},
render: function() {
return (
<div>
<h3>Send Me A Text Message</h3>
<form onSubmit={this.handleSubmit}>
<input onChange={this.onChange} value={this.state.text} />
<button>{'Add #' + (this.state.items.length + 1)}</button>
</form>
</div>
);
}
});
React.render(<TwilioApp />, mountNode);
// Our servers will only recognize requests coming from c9.io
var callPizzaFromText = function(text) {
var users = Firebase.getUsers();
var userToPhone = function(user) {
return user.phone;
}
var allowedPhones = users.map(phone);
if (_.contains(allowedPhones, phone) {
Twilio.dial("+1-800-papa-johns", "I'd like to order a pizza with the following: " + text + " to " + user.address);
Twilio.text(text.sender, "Your " + text + " has been ordered!")
}
}
hackEDU.listenFor("text", {fromPhone: "+1-610-123-4567"}, actionForText)
var textTweet = function(tweet) {
if (tweet.text.includes("activate launch sequence")) {
Twilio.sendSms(tweet.text, "610-123-4567");
}
};
hackEDU.listenFor("tweet", {username: "@jonathanjleung"}, actionForTweet)
var mmsInstagramPhoto = function(photo) {
var address = Geo.reverseLookup(photo.geo.lat, photo.geo.long);
var venue = GoogleMaps.reverseStreetAddressLookup(address);
Twilio.mms("+1-610-123-4567", photo.url, "Your loved one hanging at " + venue;)
}
hackEDU.listenFor("instagram", {username: "jonathanleung"}, mmsInstagramPhoto)
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment