Hello,
I'm trying to implement twilio to my app using the cloud code, this is my code so far:
Parse.Cloud.define("sendSMSProvider",function(request,response){
//require the Twilio module and create a REST client
var client = require('twilio')('SID','AUTH_TOKEN');
//Send an SMS text message
console.log("Sending SMS");
client.sendMessage({
// you can use request.params to pass the number you want to send
to:'insert_num', // Any number Twilio can deliver to
from: 'insert_num', // A number you bought from Twilio and can use for outbound communication
body: 'SMS From Cloud Code.' // body of the SMS message
}, {
success:function(success){
// console.log(success);
response.success(success);
},
error:function(error){
// console.log(error);
response.error(error);
}
});
});
It's sending me the text message, but 3 times. Through my code in app it executes the cloud code once, but I see in my logs "Sending SMS" like 4 times.
If I remove everything that involves twilio, then I see the logged "Sending SMS" just once.
I'm also receiving this error message from ios itself:
"Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}"
Is there anything wrong that I'm doing? Any help is appreciated.