登录后无法使用 ACS REST API 发送推送通知

Unable to send push notification with ACS REST API after login

本文关键字:API 通知 REST ACS 登录      更新时间:2023-09-26

我想在我的网站上创建一个HTML/JavaScript表单。通过这种形式,我也喜欢发送推送通知 安卓和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 函数时,我收到一个响应错误:响应错误: "状态":"失败", "代码":400, "消息":"无法对用户进行身份验证"。

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);
    };
}