메뉴 건너뛰기

조회 수 485 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

. 게시판 관리자에서

test

게시판을 만들어 준다.

 

1. 테마의 tail.php 나 index.php 혹은 적당한 곳에 아래 스크립트 넣기

- 자동으로 밴드글을 가져오는 역할을 함.

 

<script>

$.ajax({
    url: '/api/band_posts.php', // 요청 할 주소
    async: false, // false 일 경우 동기 요청으로 변경
    type: 'POST', // GET, PUT
    data: {
    }, // 전송할 데이터
    dataType: 'text', // xml, json, script, html
    success: function(jqXHR) {console.log('success');}, // 요청 완료 시
    error: function(jqXHR) {console.log('error');}, // 요청 실패.
});

</script>

 

 

 

 

2. 해당 경로에 아래 파일 만들어 넣기

 

/*    /api/band_posts.php  */

 

<meta charset="utf-8">
< ?
include_once('./_common.php');

/*
https://developers.band.us
네이버 밴드 개발자 사이트에서 내 서비스등록후, Aaccess Token 을 발급받는다.


밴드 목록에서 밴드키 찾기 부분, 밴드키를 찾은 후에는 해당 부분만 주석처리 한다.
*/


/************************************************************************************

$url = 'https://openapi.band.us/v2.1/bands';

$ch = curl_init();

$data = "access_token=네이버 밴드에서 발급받은 토큰키를 넣는다.";

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, 0); // 헤더 출력 여부
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 결과값을 받을것인지

$result=curl_exec($ch);

curl_close ($ch);

var_dump($result);

**************************************************************************************/

 

 

 


//밴드 게시글 가져오기

$url = 'https://openapi.band.us/v2/band/posts';

$ch = curl_init();

$data = "access_token=네이버 밴드에서 발급받은 토큰키를 넣는다.&band_key=위밴드키 찾기부분에서 얻은 밴드키를 넣는다.";

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, 0); // 헤더 출력 여부
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 결과값을 받을것인지

$result=curl_exec($ch);

curl_close ($ch);


$jsonData = json_decode($result, true);

$bo_table = "test";

// 게시판 ID를 넣는다.


$write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름

foreach ($jsonData['result_data']['items'] as $items) {

 //포스트글 중복체크
 $cnt = sql_fetch("select wr_id from $write_table where wr_1 = '".trim($items['post_key'])."' ");
 if( $cnt>0 || $items['content']=='Uploaded event.' ) {
  continue;
 } else {

  $wr_date_time = date('Y-m-d H:i:s',substr($items['created_at'],0,10));
  $wr_subject = "네이버 밴드글 (".substr($wr_date_time,0,10).")";
  // 제목은 적당하게 넣어 준다.

  $wr_content = substr(trim(nl2br($items['content'])),0,65536);
  $wr_content = preg_replace("#[\\\]+$#", "", $wr_content);

  $mb_id = "admin";
  $wr_name = "운영자";
  // 게시자 이름도 적당하게 넣어 준다.

  $wr_password = get_encrypt_string("1a2a3a4a5a6a");
  $wr_email = '';

  $wr_num = get_next_num($write_table);
  $wr_reply = '';
  $html = "html2";

  // 포스트 키
  $wr_1 = trim($items['post_key']); 

  $tmp_photo = "";
  foreach($items['photos'] as $photo){
   $tmp_photo .= '<img src="'.$photo['url'].'" alt="band images" ><br><br>';
  }

  $wr_content .= $tmp_photo;

  $sql = " insert into $write_table
   set wr_num = '$wr_num',
     wr_reply = '$wr_reply',
     wr_comment = 0,
     ca_name = '',
     wr_option = '$html,$secret,$mail',
     wr_subject = '$wr_subject',
     wr_content = '$wr_content',
     wr_link1 = '',
     wr_link2 = '',
     wr_link1_hit = 0,
     wr_link2_hit = 0,
     wr_hit = 0,
     wr_good = 0,
     wr_nogood = 0,
     mb_id = '{$mb_id}',
     wr_password = '$wr_password',
     wr_name = '$wr_name',
     wr_email = '$wr_email',
     wr_homepage = '',
     wr_datetime = '".$wr_date_time."',
     wr_last = '".$wr_date_time."',
     wr_ip = '{$_SERVER['REMOTE_ADDR']}',
     wr_1 = '$wr_1',
     wr_2 = '',
     wr_3 = '',
     wr_4 = '',
     wr_5 = '',
     wr_6 = '',
     wr_7 = '',
     wr_8 = '',
     wr_9 = '',
     wr_10 = '' ";
  
  sql_query($sql);

  $wr_id = sql_insert_id();

  // 부모 아이디에 UPDATE
  sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' ");

  // 새글 INSERT
  sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) ");

  // 게시글 1 증가
  sql_query("update {$g5['board_table']} set bo_count_write = (select count(wr_id) from  $write_table where 1=1) where bo_table = '{$bo_table}'");
 }
}

?>

 

 

 

3. 밴드 게시물은 등록된 역순으로 가져오게 되므로,

게시판 관리자에서 정렬순서를 wr_datetime desc 로 변경해 준다.

 

4. 다음 작업할때 쓸려고 팁자료실에 남겨 본다. 끝.

 

5. 추가

=================

 

해당 경로에 파일 만들기

/*    /api/_common.php  */

 

<?php
include_once('../common.php');
?>

 

/*

이 파일이 없으면 오류가 나고 DB 연결이 안됨.

그누보드 기본내용이라서 생략하였으나, 추가함.

*/


List of Articles
번호 제목 날짜 조회 수
50 유튜브 동영상 시간체크 후 폼 전송하기 2024.04.09 0
49 mov 업로드시 mp4 자동 변환 file 2024.04.09 0
48 웹상에서 PDF 뷰어 소스 (copyright 2021 Mozilla) file 2024.04.09 1
47 특정국가 차단하기 2024.04.09 1
46 NICE API 인증모듈 file 2024.04.09 1
45 엑셀파일 읽어서 바로 DB에 업로드하기 file 2024.04.09 2
44 admin 비밀번호 생각이 안 날때, 비번 바꾸는 간단한 소스 (SHA256 용) 2024.04.09 3
43 접속주소가 https로 되여 있는지 판단하여 $g5_path['url']를 수정하기 2024.04.09 8
42 회원가입 못하게 2023.01.05 79
41 mysql concat 날짜와 시간을 문자열로 합치기 시간의 크기 비교 2023.05.16 131
40 회원 등급(권한)에 따라서 다른 메시지 보이기 2021.03.24 146
39 그누보드 이력서 스킨 file 2021.03.24 151
38 style 수정시 서버에서 로딩되게 하기 2019.12.13 255
37 그누보드 카카오톡 로그인 V2 플러그인 file 2021.03.24 289
36 카운트다운 스크립트 2019.12.13 317
35 jQuery 요소(elements) 미디어 컨버팅 플러그인 file 2019.12.13 320
34 글 작성시 랜덤형 자동 댓글로 인사 멘트남기기 2019.12.13 323
33 이름 마지막 한자리 별표 처리 2019.12.13 326
32 fullcalendar 달력 게시판 스킨 file 2021.03.24 361
31 특정 게시판에서 이미지 파일만 업로드 허용하기 file 2019.12.09 367
Board Pagination Prev 1 2 3 4 Next
/ 4

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved