웹훅 수신

2021-03-08 (월) 17:43:01 3,956

그누위즈님께서 만들어주신 코드중에 잔디로 웹훅을 수신받아 알림을 띄우는 기능인데요

모든게시판적용은 /bbs/write_update.php 하단에 작성하면된다고 하셨는데

적용이안되네요 혹시몰라서 코드 올려볼게요

Copy
<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/naver_syndi.lib.php');
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');

 

 

//*중략*//

 

 

// 사용자 코드 실행
@include_once($board_skin_path.'/write_update.skin.php');
@include_once($board_skin_path.'/write_update.tail.skin.php');

delete_cache_latest($bo_table);

$redirect_url = run_replace('write_update_move_url', short_url_clean(G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table.'&amp;wr_id='.$wr_id.$qstr), $board, $wr_id, $w, $qstr, $file_upload_msg);

run_event('write_update_after', $board, $wr_id, $w, $qstr, $redirect_url);

if ($file_upload_msg)
    alert($file_upload_msg, $redirect_url);
else
    goto_url($redirect_url);

 

// 잔디로 보내기 (gnuwiz)
function jandi_post($data)
{
    $data = json_encode($data);
 
    $headers[] = "Accept: application/vnd.tosslab.jandi-v2+json"; // 신규 API 키
    $headers[] = "Content-type: Application/json";
 
$url = "webhook/API URL 제주소 넣음"; // API URL
 
    $curl = curl_init();
 
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_VERBOSE, true);
 
    $response = curl_exec($curl);
 
    curl_close($curl);
 
    $response = json_decode($response, true);
 
    return $response;
}
 
if ($w == '') { // 새글 작성일 경우에만 API 사용
$data = array();
$data['body'] = "[[{$config['cf_title']}]](".G5_BBS_URL."/board.php?bo_table=".$bo_table."&wr_id=".$wr_id.") 게시글이 등록되었습니다.";
$data['connectColor'] = "#FAC11B";
$data['connectInfo'][] = array("title" => $wr_subject, "description" => $wr_content);
 
$response = jandi_post($data); // 잔디로 전송
}

답변 1개 / 댓글 1개

Copy
goto_url($redirect_url); <--이것으로 인하여 페이지 이동이 일어나 버린 후에

 jandi_post($data);<-- 이게 실행 될 수 없습니다

// 사용자 코드 실행 <---이것 앞으로 옮기세요

답변에 대한 댓글 1개

2021-03-09 (화) 09:52:05
앞으로 옮겨도 잘안되네요.. 테마게시판을 바꿔야하나요

답변을 작성하려면 로그인이 필요합니다.