나는 http://cp.pushwoosh.com/json/1.3/createMessage에 JSON 데이터의 조각을 게시하고 구체적으로, 데이터가nodejs와 pushwoosh 알림을 보내는 방법은 무엇입니까?
{'application' : PW_APPLICATION,
'auth' : PW_AUTH,
'notifications':{
'send_date' : 'now',
'content' : 'test',
'data' : {
'custom' : 'json data'
},
'link' : 'http://pushwoosh.com/'
}
}
등의 형식으로 포장됩니다 통지를 보내도록 pushwoosh의 romote API를, 기본 과정입니다 공부했습니다 pushwoosh 가이드는 Java, PHP, Ruby 등의 샘플 코드의 serveral을 나열합니다. pushwoosh가 nodejs 버전을 제공하지 않는다는 것이 매우 혼란 스럽습니다. 그래서 나 혼자서 수행해야합니다. 'http'모듈을 사용하여 요청, 매개 변수 및 주요 코드의 일부가 아래에 표시됩니다.
var bodyArgs =
{'application' : PW_APPLICATION,
'auth' : PW_AUTH,
'notifications':{
'send_date' : 'now',
'content' : 'test',
'data' : {
'custom' : 'json data'
},
'link' : 'http://pushwoosh.com/'
}
}
var bodyArgsArray = [];
for (var i in bodyArgs) {
if (bodyArgs.hasOwnProperty(i)) {
if(typeof bodyArgs[i] == 'object'){
bodyArgsArray.push(i + '=' + (JSON.stringify(bodyArgs[i])));
}else{
bodyArgsArray.push(i + '=' + (bodyArgs[i]));
}
}
}
var options = {
host: 'cp.pushwoosh.com',
method: 'POST',
path: '/json/1.3/createMessage',
headers: {'Content-Length': bodyStr.length,
'Content-Type':'application/json',
'Access-Control-Allow-Origin':'*'
}
var req = http.request(options, function (res){...});
불행히도, 요청이 성공적으로 처리되는 경우 lformed 응답
[syntax error at end of input]
는 올바른 반응은 꽤 사람의 nodejs 버전의 감사
{
"status_code":200,
"status_message":"OK",
"response": {
"Messages":["{Notification code}", "{Notification code}", ...]
}
}
내가 format.I이 될 것입니다 올바른 요청을 알아낼 수있는 좋은 욕망을 가지고있을 shoule 가능하다면!
그리고 pushwoosh 원격 API 가이드 웹 사이트는 내가이 작업을 얻는 방법을 알아 냈
https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/
nluo을 푸시 알림을 보내도록 작성했습니다, 태그에 대해 제한하기 위해 무엇을 전송 ...? – ChrisH
@ChrisH 옵션 매개 변수 – nluo
내에서 태그를 사용하면 도움이됩니다. 나는 땜장이로 일하고있어. 미안해. 내 의견을 수정/삭제하지 않았다. 태그 메커니즘은 아마도 약간 장황하고 반복적이라면 괜찮습니다. 감사! – ChrisH