我想在我的网站上创建一个html / javascript表单。随着形式我喜欢发送Android和iOS设备的推送通知。
登录http请求正常工作:
httpRequest.open('POST','https://api.cloud.appcelerator.com/v1/users/login.json?key=xxxAPKEYxxx&login=xxxEMAILxxx&password=xxxPASSWORDxxx');
httpRequest.send();
httpRequest.onload = function(){
var data = JSON.parse(this.responseText);
var sessionID = data.meta.session_id;
sendPush();
}
回复:{" meta":{" code":200," status":" ok"," method_name":" loginUser" ....因此登录成功。但是当我调用sendPush函数时,我得到一个响应错误:响应错误: "状态":"失败&#34 ;, "代码":400, " message":"无法验证用户"。
function sendPush(){
httpRequest.open('POST','https://api.cloud.appcelerator.com/v1/push_notification/notify.json?key=xxxAPPKEYxxx&channel=xxxCHANNELxxx&payload=test');
httpRequest.send();
httpRequest.onload = function()
{
console.log(this.responseText);
};
}
答案 0 :(得分:0)
function sendPush(){
var BASEURL = 'https://api.cloud.appcelerator.com/v1/'
httpRequest.open('POST', BASEURL + 'push_notification/notify.json?key=APPKE');
httpRequest.send({
channel : "xxxCHANNELxxx",
payload : "test"
});
httpRequest.onload = function() {
console.log(this.responseText);
};
}