1. 기존 서버 이용 또는 신규 서버 생성. (기존서버 이용시 자기가 웹훅 관리 권한 있어야됨)
-> 이거는... 따로 설명 필요 없다고 봅니다!
2. 웹훅 만들기
3. WEBHOOK URL 이 $endpoint 부분에 들어가면 됨 (POST 요청 타겟)
4. PHP 구현 소스
$endpoint = "https://discordapp.com/api/webhooks/[AUTH_TOKEN]";
$msg = "보낼 푸시 알림 내용";
$json_data = array
(
"content" => $msg,
"embeds" => array ( // 푸시에 이미지도 첨부 가능 (더 다양한 형식은 https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html 참고)
array
(
"image" => array("url"=>"https://i.imgur.com/~~~.jpg")
)
)
);
$make_json = json_encode($json_data);
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
5. 이런식으로 구현해놓으면 해당 php url 접속시 설정된 디스코드 서버로 푸시가 날라감.
webhook 이용하여 간단하지만 다양하게 응용 가능.
정말... 간단하죠?
그럼 전 20000
댓글 달기