api 테스트 용 서버 > RESTful

RESTful

api 테스트 용 서버 정보

api 테스트 용 서버

본문

https://allthatnba.com/api

https://github.com/ohah/gnubaord_api

 

사용 가능버전은 7.2X 이상.

7.X 이상 버전에도 동작할거라 생각하지만 그 이하나 그 이상의 버전에선 테스트 해보지 않았습니다.

 

자세한건 api/index.php를 참조하세요

현재 데모는 아파치 서버 기준으로 동작됩니다.

추후 ngnix까지는 사용지원 예정에 있습니다


<?php
$router->get('/', function() use ($api) {
  echo "테스트 그누보드입니다.";
  //$api->sql_query();
});
$router->match('GET|POST', '/Auth/{mb_id}', function($mb_id) use ($api) {
  if(!$_POST['mb_password']) {
    $api->msg('패스워드를 입력해주세요');
    exit;
  }
  $mb_password = $_POST['mb_password'];
  $api->Login($mb_id, $mb_password);
});
$router->match('GET', '/configs', function() use ($api){
  echo json_encode($api->get_config(), JSON_UNESCAPED_UNICODE);
});
$router->mount('/contents', function() use ($router, $api) {
  $router->get('/', function() use ($api) {
    echo $api->get_content($co_id);
  });
  $router->get('/(\w+)', function($co_id) use ($api) {
    echo $api->get_content($co_id);
  });
});
$router->mount('/faqs', function() use ($router, $api) {
  $router->get('/', function() use ($api) {
    echo $api->get_faq($fa_id);
  });
  $router->get('/(\w+)', function($fa_id) use ($api) {
    echo $api->get_faq($fa_id);
  });
});
$router->match('GET', '/faqsgroup/{fm_id}', function() use ($api){
  echo $api->get_faq_group($fa_id);
});
$router->match('GET', '/groups', function() use ($api){
  echo json_encode($api->get_group($fa_id), JSON_UNESCAPED_UNICODE);
});
$router->match('GET', '/members', function() use ($api){
  echo $api->get_members();
});
$router->mount('/member', function() use ($router, $api) {
  $router->get('/{mb_id}/scraps', function($mb_id) use ($api) {
    echo $api->get_scrap($mb_id);
  });
  $router->get('/{mb_id}/points', function($mb_id) use ($api) {
    echo $api->get_point($mb_id);
  });
  $router->get('/{mb_id}', function($mb_id) use ($api) {
    echo json_encode($api->get_member($mb_id), JSON_UNESCAPED_UNICODE);
  });
});
$router->match('GET', '/boards', function() use ($api){
  echo $api->get_board();
});
$router->mount('/board', function() use ($router, $api) {
  $router->match('GET', '/new_articles', function() use ($api){
    echo $api->get_new_articles();
  });
  $router->match('GET', '/new_comments', function() use ($api){
    echo '지원예정';
  });
  $router->get('/{bo_table}/{wr_id}/good', function($bo_table, $wr_id) use ($api) {
    echo $api->get_board_good($bo_table, $wr_id);
  });
  /**
   * 작성자 제외, 회원만 가능
   * @param bo_table address;
   * @param wr_id address;
   * @param good,nogood address;
   */
  $router->match('POST|PUT', '/{bo_table}/{wr_id}/{good}', function($bo_table, $wr_id, $good) use ($api) {
    echo $api->good($bo_table, $wr_id, $good);
  });
  $router->get('/{bo_table}/{wr_id}/files', function($bo_table, $wr_id) use ($api) {
    $api->board_chk($bo_table, $wr_id);
    echo $api->get_board_file($bo_table, $wr_id);
  });
  $router->get('/{bo_table}/{wr_id}/comments', function($bo_table, $wr_id) use ($api) {
    $api->board_chk($bo_table, $wr_id);
    echo $api->get_cmt_list($bo_table, $wr_id);
  });
  $router->get('/{bo_table}/{wr_id}/comment/{comment_id}/good', function($bo_table, $wr_id, $comment_id) use ($api) {
    $api->board_chk($bo_table, $wr_id);
    echo $api->get_board_good_cmt($bo_table, $wr_id, $comment_id);
  });
  $router->get('/{bo_table}/{wr_id}/comment/{comment_id}/files', function($bo_table, $wr_id, $comment_id) use ($api) {
    $api->board_chk($bo_table, $wr_id);
    echo $api->get_board_file_cmt($mb_id);
  });
  $router->get('/{bo_table}/{wr_id}/comment/{comment_id}', function($bo_table, $wr_id, $comment_id) use ($api) {
    $api->board_chk($bo_table, $wr_id);
    echo $api->get_view_cmt($mb_id);
  });
  /**
   * 글 삭제
   * 작성자, 관리자만 가능
   * @param bo_table address;
   * @param wr_id address;
   * @param comment_id address;
   */
  $router->match('DELETE|POST', '/{bo_table}/{wr_id}/comment/{comment_id}', function($bo_table, $wr_id, $comment_id) use ($api) {    
    echo $api->delete_comment($bo_table, $wr_id);
  });
  /**
   * 글보기 view.php
   * @param bo_table 테이블ID
   * @param wr_id 글ID
   */
  $router->get('/{bo_table}/{wr_id}', function($bo_table, $wr_id) use ($api) {
    $api->board_chk($bo_table, $wr_id);
    echo $api->get_views($bo_table, $wr_id);
  });
  /**
   * 작성자, 관리자만 가능
   * @param bo_table address;
   * @param wr_id address;
   * @param wr_password post;
   */
  $router->match('DELETE|POST', '/{bo_table}/{wr_id}', function($bo_table, $wr_id) use ($api) { //삭제 
    echo $api->delete($bo_table, $wr_id);
  });
  $router->get('/{bo_table}', function($bo_table) use ($api) {
    $api->board_chk($bo_table);
    echo $api->get_bbs_list($bo_table);
  });
  /**
   * 관리자만 가능
   * @param bo_table address;
   * @param POST chk_wr_id;
   */
  $router->match('DELETE|POST', '/{bo_table}/all', function($bo_table, $wr_id) use ($api) { //삭제 
    echo $api->delete_all($bo_table, $wr_id);
  });
});
/**
 * 글쓰기
 * @param write(글수정)
 * @param write_update(글수정)
 * @param write_update(글쓰기)
 * @param write(글쓰기)
 */
$router->mount('/write', function() use ($router, $api) {
  $router->match('GET|POST', '/{bo_table}/{wr_id}/{w}', function($bo_table, $wr_id, $w) use ($api) {
    $api->write($bo_table, $wr_id, $w);
  });
  $router->match('PUT|POST', '/{bo_table}/{wr_id}', function($bo_table, $wr_id) use ($api) {
    $api->board_chk($bo_table);
    echo $api->write_update($bo_table, $wr_id);
  });
  $router->match('PUT|POST', '/{bo_table}', function($bo_table) use ($api) {
    $api->board_chk($bo_table);
    echo $api->write_update($bo_table);
  });
  $router->match('GET', '/{bo_table}', function($bo_table) use ($api) {
    $api->write($bo_table);
  });
});
$router->match('GET', '/menus', function() use ($api){
  echo json_encode($api->get_menu_db(), JSON_UNESCAPED_UNICODE);
});
$router->match('GET', '/autosave', function() use ($api){
  echo $api->get_autosave();
});
/**
 * 프로필
 * @param mb_id 맴버 아이디
 */
$router->match('GET', '/profile/{mb_id}', function($mb_id) use ($api){
  echo $api->profile($mb_id);
});
/**
 * 비밀번호
 * @param w sc, c, u, r 등 요청에 맞는 그누보드 기본값
 * @param bo_table 테이블 이름
 * @param wr_id wr_id 값
 */
$router->match('POST', '/password/{w}/{bo_table}/{wr_id}', function($w, $bo_table, $wr_id) use ($api){
  echo $api->password_check($w, $bo_table, $wr_id);
});
/**
 * 최신글
 * @param bo_table 테이블명
 * @param rows 개수
 * @param subject_len 제목길이
 */
$router->match('GET', '/latest(/[a-z0-9_-]+)?(/[0-9_-]+)?(/[0-9_-]+)?', function($bo_table, $rows, $subject_len) use ($api) {
  $rows = $rows ? $rows : 10;
  $subject_len = $subject_len ? $subject_len : 40;
  echo $api->latest($bo_table, $rows, $subject_len);
});
/**
 * 인기검색어
 * @param pop_cnt 검색어 개수(기본값 7)
 * @param date_cnt 날짜(기본값 3)
 */
$router->match('GET', '/popular(/[0-9_-]+)?(/[0-9_-]+)?', function($pop_cnt = 7, $date_cnt = 3) use ($api){
  $pop_cnt = $pop_cnt ? $pop_cnt : 7;
  $date_cnt = $date_cnt ? $date_cnt : 7;
  echo json_encode($api->popular($pop_cnt, $date_cnt), JSON_UNESCAPED_UNICODE);
});
 
/**
  * 관리자만 가능
  * @param qa_id address;
*/
$router->match('GET', '/qa/{qa_id}', function($qa_id) use ($api){
  echo json_encode($api->qaview($qa_id), JSON_UNESCAPED_UNICODE);
});
 
/**
 * 전부다 포스트로 처리
 * @param _POST post;
 */
$router->match('POST|PUT', '/register', function() use ($api) {
  echo json_encode($api->register(), JSON_UNESCAPED_UNICODE);
});
$router->match('POST|PUT', '/register_form', function() use ($api) {
  echo json_encode($api->register_form(), JSON_UNESCAPED_UNICODE);
});
$router->match('POST|PUT', '/register_form_update', function() use ($api) {
  echo json_encode($api->register_form_update(), JSON_UNESCAPED_UNICODE);
});
$router->match('GET', '/test', function() use ($api) {
  echo json_encode($api->kcaptcha_json(), JSON_UNESCAPED_UNICODE);
});
$router->match('GET', '/t', function() use ($api) {
  echo json_encode($api->chk_captcha(), JSON_UNESCAPED_UNICODE);
});
$router->mount('/captcha', function() use ($router, $api) {
  $router->match('GET', '/K', function() use ($api) {
    require API_PATH.'/plugin/kcaptcha/kcaptcha_image.php';
  });
});


https://sir.kr/so_app/1948

 

부분을 많이 참조하였으며 해당 부분에 적용되지 않는 부분의 개발의 경우 임의의 라우팅을 해놨습니다.

index.php에서 주석을 보시면 알거라 생각합니다.

 

기본적인 회원가입, 캡챠, 비밀글 접근, 게시판 보기 게시판 리스트(페이지뷰), 검색등은 가능하며

검색이나 페이지 변수 시 필요한 변수는 현재 그누보드와 동일합니다

sca stx 등..

글쓰기나 글보기 리스트에서는 현재 보이는데에 필요없는 기존 그누보드 데이터도 일부 리턴하고 있습니다.

 

로그인의 경우 Auth/mb_id

쪽으로 접근하여 post값으로 mb_password를 입력하여 보내주시면 됩니다. 

테스트 서버의 경우 test/test로 로그인할 수 있습니다.

 

테스트 개발버전이기에 각각 페이지 접속시 리턴 규약이나 리턴 json형식은 문서화 하지 않았습니다.

추천
1

댓글 3개

테스트만 해 주셔도 도움이 됩니다. Postman으로 열심히 날려 보세요.

바로 테스트해 볼 수 있게  데모 데이타도 미리미리 만들어 두었습니다. https://sir.kr/pauction/4076
전체 96 |RSS
RESTful 내용 검색

회원로그인

진행중 포인트경매

  1. 참여87 회 시작24.04.12 12:32 종료24.04.19 12:32
  2. 참여52 회 시작24.04.12 12:32 종료24.04.19 12:32
(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT