Trying to use the "Building an app with a password recovery feature", but using Text message instead of email to send secret code. I am using Twilio for this (of course). My Twilio account is set up correctly, and I can successfully use it with the Twilio Sample app provided here in Appery.
However, when I try to use it server side, I get a NullPointer exception. Here is the code snippet that has the problem:
code
var sendURL = "https://" + accountSid + ":" + authToken + "@api.twilio.com/2010-04-01/Accounts/" + accountSid + "/SMS/Messages.json"
console.log(sendURL);
console.log(phone);
console.log(PhoneNumber);
var XHRResponse = XHR.send("POST", sendURL, {
"parameters": {
"To": phone,
"Body": "Your recovery code is: " + secretCode + ". Copy and this code into the field provided.",
"From": PhoneNumber
}
});
console.log("XHR done");
/code
The first three console.log statements print fine, and I can see that the 3 variables are getting set correctly. However, the 4th one never gets there, instead I get NullPointer exception.
Maybe I am missing something obvious, but could someone please give me a pointer? I am totally out of ideas! Could it be the problem that the non-paid Twilio account (trial account) not work from server side, but only from client side?
Thanks,
-Kal.