我用jquery创建了twilio sms verificaton的ajax调用。我正确传递所有参数并仅获得肯定响应,但这些消息未传递给该号码。 这是我的ajax代码,
$("#btnSubmit").click(function(){
// Your Twilio credentials
var SID = "SID_KEY";
var Key = "AUTH_TOKEN";
$.ajax({
type: 'POST',
url:'https://api.twilio.com/2010-04-01/Accounts/'+SID+'/Messages',
data: {
"To" : "+xxxxxxxxxx",
"From" : "+yyyyyyyyy",
"Body" : "Hello World"
},
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(SID + ':' + Key));
},
success: function(data) {
console.log(1);
console.log(data);
},
error: function(data) {
console.log(data);
}
});
});
响应,
account_sid: "SID_KEY"
api_version: "2010-04-01"
body: "Sent from your Twilio trial account - Hello World"
date_created: "Sun, 27 Nov 2016 18:08:55 +0000"
date_sent: null
date_updated: "Sun, 27 Nov 2016 18:08:55 +0000"
direction: "outbound-api"
error_code: null
error_message: null
from: "+yyyyyyyyy"
messaging_service_sid: null
num_media: "0"
num_segments: "1"
price: null
price_unit: "USD"
sid: "SM2dfdfdsdadgdgadf33542352"
status: "queued"
to: "+xxxxxxxx"
uri: "/2010-04-01/Accounts/SID_KEY/Messages/SM2dfdfdsdadgdgadf33542352.json"