Webhook 사용방법
클라우드코드의 Webhook 을 활용하여 웹서비스를 제공하는 서버에 데이터를 전달 할 수 있습니다.
이를 활용하여 기구축된 서버에서 Play! NANOO 를 활용하여 데이터를 연동 할 수 있습니다.
소스 코드
// GET Sample
var url = "https://api.playnanoo.com/cloudcode/request/get";
var headers = {
'content-type' : 'application/x-www-form-urlencoded'
};
var contents = {
q1 : "QueryString1",
q2 : "QueryString2"
};
var result = http.request('GET', url, headers, contents);
log.debug(result);
// POST Sample
url = "https://api.playnanoo.com/cloudcode/request/post";
headers = {
'content-type' : 'application/x-www-form-urlencoded'
};
contents = {
formData1 : "Data1",
formData2 : "Data2"
};
var result = http.request('POST', url, headers, contents);
log.debug(result);
// PUT Sample
url = "https://api.playnanoo.com/cloudcode/request/put";
headers = {
'content-type' : 'application/json'
};
contents = {
data1 : "DATA1",
data2 : "DATA2"
};
var result = http.request('PUT', url, headers, contents);
log.debug(result);
상세 정보
데이터키 | 설명 | 타입 |
---|---|---|
method | HTTP 메소드 (GET, POST, PUT, DELETE) | string |
url | 웹서비스 URL | string |
headers | HTTP 요청 헤더 | object |
contents | HTTP 요청 데이터 | object |