Parse platform SMS未从解析云代码通过PLIVO发送
我在parse.com上开发了一个应用程序 我已经创建了以下函数来使用plivo发送短信Parse platform SMS未从解析云代码通过PLIVO发送,parse-platform,parse-cloud-code,plivo,Parse Platform,Parse Cloud Code,Plivo,我在parse.com上开发了一个应用程序 我已经创建了以下函数来使用plivo发送短信 function sendRSVPSMS(PlivoNumber, GuestNumber, Message) { var payLoad = { src: PlivoNumber, dst: GuestNumber, text: Message }; Parse.Cloud.httpRequest({ url: "&l
function sendRSVPSMS(PlivoNumber, GuestNumber, Message) {
var payLoad = {
src: PlivoNumber,
dst: GuestNumber,
text: Message
};
Parse.Cloud.httpRequest({
url: "<My Plivo URL>",
method: "POST",
body: payLoad,
success: function (httpResponse) {
console.log('httpRequest success');
response.success("Sent successfully");
},
error: function (httpResponse) {
console.log('SendSMS: Request failed');
response.error('Request failed');
}
});
}
函数sendRSVPSMS(PlivoNumber、GuestNumber、Message){
var有效载荷={
src:PlivoNumber,
dst:GuestNumber,
文本:消息
};
Parse.Cloud.httpRequest({
url:“”,
方法:“张贴”,
机身:有效载荷,
成功:函数(httpResponse){
log('httpRequest success');
响应。成功(“发送成功”);
},
错误:函数(httpResponse){
log('SendSMS:Request failed');
响应。错误('请求失败');
}
});
}
原因可能是什么?可能是您忘记为内容类型指定标题 “内容类型”:“应用程序/json” 因此,您的代码如下所示
function sendRSVPSMS(PlivoNumber, GuestNumber, Message) {
var payLoad = {
src: PlivoNumber,
dst: GuestNumber,
text: Message
};
Parse.Cloud.httpRequest({
url: "<My Plivo URL>",
method: "POST",
body: payLoad,
headers: {
"Content-Type": "application/json"
},
success: function (httpResponse) {
console.log('httpRequest success');
response.success("Sent successfully");
},
error: function (httpResponse) {
console.log('SendSMS: Request failed');
response.error('Request failed');
}
});
}
函数sendRSVPSMS(PlivoNumber、GuestNumber、Message){
var有效载荷={
src:PlivoNumber,
dst:GuestNumber,
文本:消息
};
Parse.Cloud.httpRequest({
url:“”,
方法:“张贴”,
机身:有效载荷,
标题:{
“内容类型”:“应用程序/json”
},
成功:函数(httpResponse){
log('httpRequest success');
响应。成功(“发送成功”);
},
错误:函数(httpResponse){
log('SendSMS:Request failed');
响应。错误('请求失败');
}
});
}
可能是您忘记为内容类型指定标题
“内容类型”:“应用程序/json”
因此,您的代码如下所示
function sendRSVPSMS(PlivoNumber, GuestNumber, Message) {
var payLoad = {
src: PlivoNumber,
dst: GuestNumber,
text: Message
};
Parse.Cloud.httpRequest({
url: "<My Plivo URL>",
method: "POST",
body: payLoad,
headers: {
"Content-Type": "application/json"
},
success: function (httpResponse) {
console.log('httpRequest success');
response.success("Sent successfully");
},
error: function (httpResponse) {
console.log('SendSMS: Request failed');
response.error('Request failed');
}
});
}
函数sendRSVPSMS(PlivoNumber、GuestNumber、Message){
var有效载荷={
src:PlivoNumber,
dst:GuestNumber,
文本:消息
};
Parse.Cloud.httpRequest({
url:“”,
方法:“张贴”,
机身:有效载荷,
标题:{
“内容类型”:“应用程序/json”
},
成功:函数(httpResponse){
log('httpRequest success');
响应。成功(“发送成功”);
},
错误:函数(httpResponse){
log('SendSMS:Request failed');
响应。错误('请求失败');
}
});
}
这里是Plivo销售工程师
帕万是正确的。您需要将Content-Type
头指定为application/json
,以便进行解析以生成主体的json字符串:
headers: {
"Content-Type": "application/json"
},
您还应该
console.log(httpResponse)
(又称PLIVOAPI响应),它将告诉您是否做了错误的事情(发送了错误的数据,没有正确地进行身份验证)或是否做了正确的事情。无论哪种方式,它都会向您显示一个api\u id
,您可以使用它查看您的应用程序并找出需要更改的内容。您还可以通过如下url直接转到特定api\u id
的调试日志:https://manage.plivo.com/logs/debug/api/e58b26e5-3db5-11e6-a069-22000afa135b/
并将e58b26e5-3db5-11e6-a069-22000afa135b
替换为用户返回的api\u id
Parse.Cloud.httpRequest
这里是Plivo销售工程师
帕万是正确的。您需要将Content-Type
头指定为application/json
,以便进行解析以生成主体的json字符串:
headers: {
"Content-Type": "application/json"
},
您还应该
console.log(httpResponse)
(又称PLIVOAPI响应),它将告诉您是否做了错误的事情(发送了错误的数据,没有正确地进行身份验证)或是否做了正确的事情。无论哪种方式,它都会向您显示一个api\u id
,您可以使用它查看您的应用程序并找出需要更改的内容。您还可以通过如下url直接转到特定api\u id
的调试日志:https://manage.plivo.com/logs/debug/api/e58b26e5-3db5-11e6-a069-22000afa135b/
并将e58b26e5-3db5-11e6-a069-22000afa135b
替换为您的Parse.Cloud.httpRequest返回的api\u id
帕万,谢谢你的反馈。这对我来说很有效。嗨,帕万,谢谢你的反馈。这对我来说很有效。