Skip to content

Instantly share code, notes, and snippets.

@Mattieuga
Last active October 12, 2015 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mattieuga/4006463 to your computer and use it in GitHub Desktop.
Save Mattieuga/4006463 to your computer and use it in GitHub Desktop.
Code snippet for Twilio/Parse sample app
// 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"); }
});
});
// 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