푸시 API 를 이용하여 스윙투앱 푸시 발송하기
스윙투앱에서는 대시보드에서 발송하는 푸시 메시지를 API 형태로 발송하는 것을 다음과 같이 제공하고 있습니다.
사전에 협의되지 않은 방식의 API 사용과 , 무분별한 대량발송의 경우 사용에 제한을 받을 수 있습니다.
*해당 API 는 유료앱 사용자에게 제공되는 항목 입니다.
*App Id, App Key 정보는 아래 가이드에서 확인 가능합니다.
스윙투앱으로 푸시를 발송하기 위한 API
POST
https://www.swing2app.com/swapi/push_api_send_message
*APP ID, API KEY 는 API KEY 관리 페이지에서 확인 가능합니다.
Request Body
발송할 대상 사용자 아이디
(최대 100명 까지 발송가능)
단일 발송시 user_id
다중발송시 “,”로 구분하여 입력
Ex:) user_id1,user_id2
전체 발송시 -1 입력
Ex:) -1
발송 유형을 입력 푸시발송일 경우 push 라고 입력
{
// Response
result : true, // 메시지 발송 성공여부
userCount : 3 , // 발송 사용자 Count
remainSmsCount 0,
isPaymentSms : F
}
var form = new FormData();
form.append("app_id", "app_id");
form.append("app_api_key", "api_key");
form.append("send_target_list", "test");
form.append("send_type", "push");
form.append("message_title", "메시지 제목");
form.append("message_content", "메시지 내용");
form.append("message_image_url", "https://www.swing2app.co.kr/assets/images/logo.png");
form.append("message_link_url", "https://www.swing2app.co.kr/");
var settings = {
"url": "https://www.swing2app.com/swapi/push_api_send_message",
"method": "POST",
"timeout": 0,
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://www.swing2app.com/swapi/push_api_send_message")
.multiPartContent()
.field("app_id", "app_id")
.field("app_api_key", "api_key")
.field("send_target_list", "test")
.field("send_type", "push")
.field("message_title", "메시지 제목")
.field("message_content", "메시지 내용")
.field("message_image_url", "https://www.swing2app.co.kr/assets/images/logo.png")
.field("message_link_url", "https://www.swing2app.co.kr/")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.swing2app.com/swapi/push_api_send_message',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('app_id' => 'app_id','app_api_key' => 'api_key','send_target_list' => 'test','send_type' => 'push','message_title' => '메시지 제목','message_content' => '메시지 내용','message_image_url' => 'https://www.swing2app.co.kr/assets/images/logo.png','message_link_url' => 'https://www.swing2app.co.kr/'),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
아래의 Postman 링크를 참고하여 각 언어별 사용예제를 참고해보세요
[javascript 구현 예시 – 전체발송]
var apiKey = "test_api_key";
var appId = "test_app_id";
var sendTargetList = '-1';
$.ajax({
url: "https://www.swing2app.co.kr/swapi/push_api_send_message",
type: "post",
dataType: "json",
data : {
app_id : appId,
send_target_list : sendTargetList,
send_type : 'push' ,
message_title:'메시지 제목',
message_content:'메시지 내용',
message_image_url: 'https://www.swing2app.co.kr/assets/images/logo.png',
message_link_url: 'https://www.swing2app.co.kr/',
app_api_key : apiKey
},
success: function (model) {
console.log("푸시 발송 성공");
}
});
[javascript 구현 예시 – 개별발송]
var apiKey = "test_api_key";
var appId = "test_app_id";
var sendTargetList = 'user_id';
$.ajax({
url: "https://www.swing2app.co.kr/swapi/push_api_send_message",
type: "post",
dataType: "json",
data : {
app_id : appId,
send_target_list : sendTargetList,
send_type : 'push' ,
message_title:'메시지 제목',
message_content:'메시지 내용',
message_image_url: 'https://www.swing2app.co.kr/assets/images/logo.png',
message_link_url: 'https://www.swing2app.co.kr/',
app_api_key : apiKey
},
success: function (model) {
console.log("푸시 발송 성공");
}
});