Google App Script 관련 고수님들의 도움을 구합니다.
CMS/프레임워크 | XE 1.x |
---|---|
개발 언어 | PHP 7.2 |
curl 요청에 성공했는데, 이걸 google app script 로 변환을 하지 못하고 있습니다.
curl -X POST "https://api.channel.io/open/v3/user-chats/5f726xxxxxxxxxxx/messages?botName=%EA%B0%9C%EB%B0%9C%ED%97%A4%EC%95%84%EB%A6%BC" -H "accept: application/json" -H "Content-Type: application/json" -H "x-access-key: 5f72xxxxxxxxxx" -H "x-access-secret: 342b0xxxx" -d " { \"chatKey\": \"userChat-5f7264x\", \"id\": \"5f729xxxxxxxxxxxxxxxxxxxxxxx\", \"channelId\": \"33086\", \"chatType\": \"userChat\", \"chatId\": \"5f7264xxxxxxxxxx\", \"personType\": \"manager\", \"personId\": \"68813\", \"requestId\": \"4dcb5dxxxxxxxxxx\", \"createdAt\": 1601xxxxxxxxxx, \"version\": 1, \"blocks\": [ { \"type\": \"text\", \"value\": \"ㅎㅎ\" } ], \"plainText\": \"ㅎㅎ\" },"
이건 성공
그런데,
function test3() {
var discordUrl = "https://api.channel.io/open/v3/user-chats/5f72645400d9e834ea42/messages?botName=개발헤아림";
var params = {
'method': 'POST',
headers: {
'accept': 'application/json',
'ContentType': 'application/json',
'x-access-key': '5f72651xxxxxxxxxx',
'x-access-secret': '342b0f6dfxxxxxxxxxx',
},
"chatKey": "userChat-5f72xxxxxxxxxx",
"id": "5f729323xxxxxxxxxx",
"channelId": "33086",
"chatType": "userChat",
"chatId": "5f72645xxxxxxxxxx",
"personType": "manager",
"personId": "68813",
"requestId": "4dxxxxxxxxxx",
"createdAt": 1601xxxxxxxxxx,
"version": 1,
"blocks": [{
"type": "text",
"value": "Hello World"
}],
"plainText": "Hello World"
};
var response = UrlFetchApp.fetch(discordUrl, params);
var text = response.getContentText();
Browser.msgBox('테스트', text, Browser.Buttons.YES_NO_CANCEL);
Logger.log(response.getContentText());
}
요렇게 변환한건 에러가 납니다.
따로 에러코드가 뜨지 않고, 뭔가 POST 명령에 이상이 있는 듯 정상 값이 리턴되지 않습니다.
고수님들의 많은 가르침 부탁드립니다.
댓글 3
function test3(){
var message = "Hello World!";
var discordUrl = "https://api.channel.io/open/v3/user-chats/5f7264/messages?botName=%EA%B0%9C%EB%B0%9C%ED%97%A4%EC%95%84%EB%A6%BC";
var payload1 = {
"chatKey": "userChat-5f72645",
"id": "5f72932",
"channelId": "386",
"chatType": "userChat",
"chatId": "5f726434ea42",
"personType": "manager",
"personId": "683",
"requestId": "4dcb55b1c",
"createdAt": 160199,
"version": 1,
"blocks": [
{
"type": "text",
"value": message,
}
],
"plainText": message,
}
var params = {
'method': 'post',
'contentType': 'application/json',
'headers': {
'x-access-key': '5f4bbf',
'x-access-secret': '342b0698327',
},
'payload': JSON.stringify(payload1)
}
var response = UrlFetchApp.fetch(discordUrl, params);
var text=response.getContentText();
Browser.msgBox('테스트', text, Browser.Buttons.YES_NO_CANCEL);
Logger.log(response.getContentText());
}