메뉴 건너뛰기

조회 수 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. sql 바인딩 그누보드에서 해보기

    Date2024.04.09 Views0
    Read More
  2. 홈페이지를 특정 IP 일때 다른 페이지로 연결하기

    Date2024.04.09 Views0
    Read More
  3. 페이지 하단 커스텀 플레이어

    Date2024.04.09 Views0
    Read More
  4. 유튜브 반응형 만들기

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

    Date2024.04.09 Views2
    Read More
  6. 회원 가입 페이지에서 랜덤 닉네임 보여주기

    Date2024.04.09 Views0
    Read More
  7. 게시물 관리 기능을 업데이트

    Date2024.04.09 Views0
    Read More
  8. 날짜및 시간 선택 jquery 라이브러리

    Date2024.04.09 Views0
    Read More
  9. mysql concat 날짜와 시간을 문자열로 합치기 시간의 크기 비교

    Date2023.05.16 Views131
    Read More
  10. 회원가입 못하게

    Date2023.01.05 Views79
    Read More
  11. 그누보드 이력서 스킨

    Date2021.03.24 Views151
    Read More
  12. fullcalendar 달력 게시판 스킨

    Date2021.03.24 Views359
    Read More
  13. 그누보드 카카오톡 로그인 V2 플러그인

    Date2021.03.24 Views289
    Read More
  14. 회원 등급(권한)에 따라서 다른 메시지 보이기

    Date2021.03.24 Views146
    Read More
  15. '정상적으로 로그인하여 접근하시기 바랍니다.' 해결 방법

    Date2020.12.09 Views416
    Read More
  16. 링크 클릭시 특정영역에 페이지 불러오기 (아이프레임X)

    Date2019.12.13 Views1219
    Read More
  17. 회원 목록을 select 로 불러와서 선택시 input 에 집어넣기

    Date2019.12.13 Views586
    Read More
  18. 네이버 밴드 글 가져오기

    Date2019.12.13 Views485
    Read More
  19. 카운트다운 스크립트

    Date2019.12.13 Views317
    Read More
  20. 이름 마지막 한자리 별표 처리

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

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved