Last active
October 12, 2015 09:28
-
-
Save Mattieuga/4006463 to your computer and use it in GitHub Desktop.
Code snippet for Twilio/Parse sample app
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
// Include the Twilio Cloud Module and initialize it | |
var twilio = require("twilio"); | |
twilio.initialize("myAccountSid","myAuthToken"); | |
// Create the Cloud Function | |
Parse.Cloud.define("inviteWithTwilio", function(request, response) { | |
// Use the Twilio Cloud Module to send an SMS | |
twilio.sendSMS({ | |
From: "myTwilioPhoneNumber", | |
To: request.params.number, | |
Body: "Start using Parse and Twilio!" | |
}, { | |
success: function(httpResponse) { response.success("SMS sent!"); }, | |
error: function(httpResponse) { response.error("Uh oh, something went wrong"); } | |
}); | |
}); |
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
// Call our Cloud Function that sends an SMS with Twilio | |
[PFCloud callFunctionInBackground:@"inviteWithTwilio" | |
withParameters:@{ number : phoneNumber } | |
block:^(id object, NSError *error) { | |
[[[UIAlertView alloc] initWithTitle:@"Invite Sent!" | |
message:@"Your SMS invitation has been sent!"; | |
delegate:nil | |
cancelButtonTitle:@"Ok" | |
otherButtonTitles:nil, nil] show]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment