<?php
// 안드로이드 개별 알림 전송
$data = [
'action' => 'individual',
'app' => 'android',
'user_token' => 'FCM_토큰값',
'title' => '알림 제목',
'memo' => '알림 내용',
'url' => 'https://naver.com',
'file_url' => 'https://cdn.safetimes.co.kr/news/photo/202103/93041_72859_5525.jpg'
];
$ch = curl_init('http://124.111.85.242/push_sesanso/push_api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result['status'] === 'success') {
echo '안드로이드 알림 전송 성공';
} else {
echo '오류: ' . $result['message'];
}
?>
titlemessageimage_urlsite
{
"title": "알림 제목",
"message": "알림 내용",
"image_url": "이미지URL",
"site": "이동할URL"
}
<?php
// iOS 개별 알림 전송
$data = [
'action' => 'individual',
'app' => 'ios',
'user_token' => 'FCM_토큰값',
'title' => '알림 제목',
'memo' => '알림 내용',
'url' => 'https://naver.com',
'file_url' => 'https://cdn.safetimes.co.kr/news/photo/202103/93041_72859_5525.jpg'
];
$ch = curl_init('http://124.111.85.242/push_sesanso/push_api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result['status'] === 'success') {
echo 'iOS 알림 전송 성공';
} else {
echo '오류: ' . $result['message'];
}
?>
titlebodyimage-urlgoto
{
"title": "알림 제목",
"body": "알림 내용",
"image-url": "이미지URL",
"goto": "이동할URL"
}
<?php
// 전체 알림 전송 (모든 기기)
$data = [
'action' => 'topic',
'device_type' => 'all', // 'all', 'android', 'ios'
'title' => '전체 공지사항',
'memo' => '모든 사용자에게 보내는 중요한 공지사항입니다.',
'url' => 'https://naver.com',
'file_url' => 'https://cdn.safetimes.co.kr/news/photo/202103/93041_72859_5525.jpg'
];
$ch = curl_init('http://124.111.85.242/push_sesanso/push_api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result['status'] === 'success') {
echo '전체 알림 전송 성공';
} else {
echo '오류: ' . $result['message'];
}
?>
$data = [
'action' => 'topic',
'device_type' => 'android',
'title' => '안드로이드 전용 알림',
'memo' => '안드로이드 사용자만 받는 알림'
];
$data = [
'action' => 'topic',
'device_type' => 'ios',
'title' => 'iOS 전용 알림',
'memo' => 'iOS 사용자만 받는 알림'
];
all: 모든 기기android: 안드로이드만ios: iOS만
android_seosanso2ios_seosanso2
| 매개변수 | 타입 | 필수여부 | 설명 | 예시값 |
|---|---|---|---|---|
action |
string | 필수 | 알림 전송 방식 | 'individual' (개별) 또는 'topic' (전체) |
app |
string | 개별 시 필수 | 개별 알림 시 기기 타입 | 'android' 또는 'ios' |
user_token |
string | 개별 시 필수 | 개별 알림 시 사용자의 FCM 토큰 | 'dA1B2c3D4e5F6g7H8i9J...' |
device_type |
string | 전체 시 필수 | 전체 알림 시 대상 기기 | 'all', 'android', 'ios' |
title |
string | 필수 | 알림 제목 | '새로운 공지사항' |
memo |
string | 필수 | 알림 내용 | '중요한 업데이트가 있습니다.' |
url |
string | 선택 | 알림 클릭 시 이동할 URL | 'https://naver.com' |
file_url |
string | 선택 | 알림에 표시할 이미지 URL | 'https://cdn.safetimes.co.kr/...' |
{
"status": "success",
"message": "푸시 알림 전송 성공"
}
{
"status": "error",
"message": "오류 메시지 내용"
}