I am attempting to incorporate Twilio into my application that is running on my parse server deployed with Heroku and MongoLab. I am trying to configure by using this code in my cloud/main.js file
var twilio = require("twilio");
twilio.initialize("87se46bovanw4v5aiwy4o57","ia8o57awyov57yn875vyboe");
Parse.Cloud.define("inviteWithTwilio", function(request, response) {
// Use the Twilio Cloud Module to send an SMS
twilio.sendSMS({
From: "6543211234",
To: 8065456703,
Body: "Start using Parse and Twilio!"
}, {
success: function(httpResponse) { response.success("SMS sent!"); },
error: function(httpResponse) { response.error("Uh oh, something went wrong"); }
});
});
however, I get this response
UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.} [NSDebugDescription: JSON text did not start with array or object and option to allow fragments not set.]
I have determined that the problem lies in the first two lines when trying to initialize Twilio. I figure this is because the Twilio Cloud Module
isn't integrated into my parse server like it was with Parse Hosted cloud code, but I'm not sure. How can I fix this problem? Thanks for your time.