# 클라이언트 초기화
from koneAPI import KoneClient
import json
import os
from typing import Dict, Any
def print_response(title: str, response) -> None:
"""API 응답을 출력하는 헬퍼 함수
Args:
title: 응답 제목
response: API 응답 객체
"""
print("\n" + "=" * 50)
print(f"[{title}] 상태 코드: {response.status_code}")
try:
json_data = response.json()
print(f"응답 데이터: {json.dumps(json_data, indent=2, ensure_ascii=False)}")
except:
print(f"응답 내용: {response.text[:200]}...") # 응답 내용 일부만 출력
print("=" * 50)
def main():
# 환경 변수에서 쿠키 값 가져오기 (보안을 위해)
# export KONE_COOKIE="여기에_실제_쿠키_값_입력" 명령으로 환경 변수 설정 가능
secure_neko_cookie = os.environ.get("KONE_COOKIE", "")
if not secure_neko_cookie:
print("오류: KONE_COOKIE 환경 변수가 설정되지 않았습니다.")
print("export KONE_COOKIE='쿠키값' 명령으로 환경 변수를 설정하세요.")
return
# 다른 서브를 사용하는 클라이언트 생성
kone_client = KoneClient(secure_neko_cookie, "kone")
print("\n\n=== 다른 서브 (kone) API 호출 예시 ===")
# 다른 서브의 배너 정보 가져오기
kone_banner_response = kone_client.api.get_sub_banner()
print_response("kone 서브 배너", kone_banner_response)
# 다른 서브의 운영자 목록 가져오기
kone_moderators_response = kone_client.api.get_sub_moderators()
print_response("kone 서브 운영자 목록", kone_moderators_response)
# 다른 서브의 웹 페이지 가져오기
kone_web_response = kone_client.web.get_sub_posts()
print(kone_web_response)
# 아티클 수정 테스트
kone_client.api.edit_sub_article("게시글 아이디", "제목", "<p>내용(HTML)</p>")
# 아티클 가져오기 테스트
kone_web_article_response = kone_client.web.get_article_info("게시글 아이디")
print(kone_web_article_response)
# 댓글 작성 테스트
# kone_client.api.post_comment("댓글 아이디", "테스트")
if __name__ == "__main__":
main()
재업