登录后无法使用 ACS REST API 发送推送通知
Unable to send push notification with ACS REST API after login
我想在我的网站上创建一个 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 函数时,我得到一个响应错误:响应错误:
"status":"fail",
"code":400,
"message":"Failed to authenticate user".
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);
};
}
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);
};
}
我想在我的网站上创建一个 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 函数时,我得到一个响应错误:响应错误: "status":"fail", "code":400, "message":"Failed to authenticate user".
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);
};
}
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);
};
}