메뉴 건너뛰기

조회 수 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 연결이 안됨.

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

*/


  1. 영카트5 DB 테이블별로 덤프하기

    Date2019.04.29 Views863
    Read More
  2. 여분필드를 활용한 게시판 스킨 제작 - 여분 필드 10개 이상 사용하기

    Date2017.04.12 Views2397
    Read More
  3. 여분필드를 활용한 게시판 스킨 제작 - 기초 예제1-3

    Date2017.04.13 Views3276
    Read More
  4. 여분필드를 활용한 게시판 스킨 제작 - 기초 예제1-2

    Date2017.04.13 Views4262
    Read More
  5. 여분필드를 활용한 게시판 스킨 제작 - 기초 예제1-1

    Date2017.04.13 Views3474
    Read More
  6. 여분필드를 활용한 게시판 스킨 제작 - 기본적인 사용 방법

    Date2017.04.13 Views2892
    Read More
  7. 여분필드 확장 후 write_update.skin.php

    Date2024.04.09 Views0
    Read More
  8. 엑셀파일 읽어서 바로 DB에 업로드하기

    Date2024.04.09 Views2
    Read More
  9. 약간간단 주소복사 버튼

    Date2024.04.09 Views0
    Read More
  10. 안쓰는 DHTML 에디터 이미지와 빈폴더 일괄삭제

    Date2024.04.09 Views0
    Read More
  11. 스마트에디터2 글쓰기시 큰이미지를 자동으로 리사이징하기

    Date2024.04.09 Views0
    Read More
  12. 쉽고 간편한 인쇄 팁

    Date2019.04.29 Views743
    Read More
  13. 비회원은 ? 시간 동안 댓글을 볼 수 없게 해보자!

    Date2024.04.09 Views0
    Read More
  14. 배열을 사용해서 여분필드 한 개로 연락처 입력란 3등분하기

    Date2017.04.12 Views2292
    Read More
  15. 링크 클릭시 특정영역에 페이지 불러오기 (아이프레임X)

    Date2019.12.13 Views1223
    Read More
  16. 댓글을 잠글 수 있는 기능을 추가 해보자!!!

    Date2024.04.09 Views0
    Read More
  17. 다음날 00시에 쿠키 만료되도록 하는 방법

    Date2014.02.27 Views4411
    Read More
  18. 네이버 밴드 글 가져오기

    Date2019.12.13 Views485
    Read More
  19. 날짜및 시간 선택 jquery 라이브러리

    Date2024.04.09 Views0
    Read More
  20. 글 작성시 랜덤형 자동 댓글로 인사 멘트남기기

    Date2019.12.13 Views322
    Read More
Board Pagination Prev 1 2 3 4 Next
/ 4

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved