I'm working on cloud code in my parse.com account to send SMS messages thru a Twilio account. I am using the integrated Twilio cloud module provided by Parse. The call to sendSMS is successful if I do not include a StatusCallback param in the call. I am saving the message in Parse on the send response and would like to use the callback to update the msg status to sent or fail. The callback URL I am using is another cloud function on my parse account. I have used the Parse format for the URL which includes my App key and JS key between the https:// and the api URL:
https://appID:javascript-key=jsKey@api.parse.com/1/functions/callbackSMS
(where appID, and jsKey are the keys provided for by Parse)
When I include this URL as the StatusCallback param for my call to sendSMS, the Twilio server rejects the call. The response identifies error 21609, invalid URL. However, I can call the URL manually using CURL with success. And, the exact same URL format works fine when configured as the Messaging Request URL for the number. This is entered using the Twilio website for the number associated w/ my account.
Anyone else using Parse/Twilio module in a Cloud Function w/ advice? How to call sendSMS from Parse cloud code and supply the StatusCallback URL to receive an update at another Parse cloud function to update the msg status once the SMS is sent by Twilio? My sendSMS cloud code included for completeness:
client.sendSms({
to:'+12223334444',
from:'+1222333555',
body:'msg body from db',
StatusCallback:'https://appID:[email protected]/1/functions/callbackSMS'
}, function (err, responseData) {
if (err) {
console.log(err);
response.error(err);
} else {
var SMSLog = Parse.Object.extend("Message");
var smsLog = new SMSLog();
smsLog.save({
messageId: responseData['sid'],
dateCreated: responseData['dateCreated'],
dateUpdated: responseData['dateUpdated'],
dateSent: responseData['dateSent'],
accountSid: responseData['accountSid'],
to: responseData['to'],
from: responseData['from'],
body: responseData['body'],
status: responseData['status']
}, {
success: function (smsLog) {
response.success(responseData);
},
error: function (smsLog, error) {
response.error("failed to save sms msg");
}
});
}
});