各位老师!有时间给我解答一下。(我找个推技术群里面说,这个他们解答不了)
// 获取 token
uni.request({
url: 'https://restapi.getui.com/v2/' + appId + '/auth',
method: 'POST',
header: {
'content-type': 'application/json;charset=utf-8'
},
data: {
"sign": signs,
"timestamp": time,
"appkey": appKey
},
success: (res) => {
// token
let tokens = res.data.data.token;
// cid
let CID = plus.push.getClientInfo().clientid;
// 随机数
let randoms = '';
for (var i = 0; i < 20; i++) {
if (randoms.length > 20 || randoms.length < 25) {
randoms += Math.floor(Math.random() * 10) + 1;
}
}
// console.log(randoms, CID, tokens);
uni.request({
url: 'https://restapi.getui.com/v2/' + appId + '/push/single/cid',
method: 'POST',
header: {
'content-type': 'application/json;charset=utf-8',
'token': tokens // 每次运行他都会改变
},
data: {
"request_id": "" + randoms,
"settings": {
"ttl": 3600000
},
"audience": {
"cid": [
CID
]
},
"push_message": {
"notification": {
"title": "超标预警",
"body": "有超标车辆经过",
"click_type": "intent",
"intent": "intent:#Intent;action=android.intent.action.oppopush;launchFlags=0x14000000;component=uni.UNI9050605/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=测试标题;S.content=测试内容;S.payload=test;end"
}
}
},
success: (ress) => {
console.log(ress);
}
});
}
});
报:400,我看了个推的请求状态,说400是参数不合法
{
"data": {
"msg": "target user is invalid",
"code": 20001
},
"statusCode": 400,
"header": {
"Content-Type": "application/json;charset=utf-8",
"Date": "Fri, 29 Jan 2021 01:17:52 GMT",
"Content-Length": "45",
"Connection": "keep-alive",
"Server": "nginx"
},
"errMsg": "request:ok",
"cookies": []
}
1 个回复
初学者123 - 80后IT男
我也报了个一样的错误。楼主后来是怎么解决的?