Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
9주차 실습강의 2010. 1학기, 소프트웨어 설계 및 실험(Ⅰ) Open API API(Application Programming Interface) - 응용 프로그램에서 사용할 수 있도록 제공되는 인터페이스 Open API - 웹 서비스의 개발을 위해 서비스 업체에서 제공하는 API - Web 2.0 기반의 대표적인 서비스 - Daum, Naver, Google, Yahoo 등 Artificial Intelligence Laboratory How can use Open API? Query 요청 방법 - GET 방식 URL에 직접 데이터를 적어서 전송 ex) http://search.naver.com/search.naver?where=nexearch&query=abc.. 보안에 취약하나 form을 생성할 필요가 없음 URL에 포함되어 전달되기 때문에 길이의 제한이 있음 - POST 방식 Form을 생성하여 전송 데이터가 숨겨져서 전송이 되기 때문에 보안성이 높음 데이터의 길이 제한이 없음 XML 형식으로 결과 데이터 수신 Artificial Intelligence Laboratory 한글 Encoding 현재 인터넷에는 다양한 한글 코드가 사용 중 EUC-KR - KS 완성형 한글 코드 - 2,350개의 제한된 글자 표현 UTF-8 - UTF : Unicode Transformation Format Unicode를 표기하고 전송하기 위한 방법 8-bit 형식으로 처리 7-bit 표준 ASCII와 완벽한 호환성으로 가장 많이 사용 중 8-bit 이상으로 확장 가능 Artificial Intelligence Laboratory 한글 Encoding UTF-16 - Unicode의 기본이 되는 16-bit로 unicode를 그대로 표현 - 32-bit 까지 확장 가능 ANSI - 7-bit ASCII의 0~127 영역 외의 128~255 영역의 표준화 - 한글 표준 : ANSI-949 Artificial Intelligence Laboratory Naver Open API Key 등록 Naver Developer Center - http://dev.naver.com 좌측 메뉴 – 키 이용등록/수정 메뉴 E-mail / 연락처 / 사용용도 등록 Key List91e882eb2e55c968beef20fe6ea126d3 b8de24e13095b21049d660471bbc72c7 f5e0e9e35bba47b9ddc09f9f5fb23219 87b0c706f01ebc494df5ea894a6c0aaa 9863d2dd8e80a25d07eb2f9c002dff90 c9864c38585e5d5ed8f3e426b3d2c4dc 6f4ad5dbec8f118d6869767b9fbcefe4 f32441ebcd3cc9de474f8081df1e54e3 네이버 아이디가 없다면 이중에서 되는것 사용해도 됨 Artificial Intelligence Laboratory Naver 검색 API 참조: http://dev.naver.com/openapi/apis/search/webkr 해당 변수 값을 넣고 request 요청 Artificial Intelligence Laboratory Naver 검색 API 출력 결과 필드 Artificial Intelligence Laboratory Naver 검색 API 결과 sample data Artificial Intelligence Laboratory 구글 검색 API 참조: http://code.google.com/intl/ko/apis/ajaxsearch/documentation/ Artificial Intelligence Laboratory 구글 검색 API 참조: http://code.google.com/intl/ko/apis/ajaxsearch/documentation/ Google AJAX 검색 API는 자바스크립트 라이브러리 html 코드에 ‘<script>’형식으로 삽입가능 ASP .NET 의 코드비하인드에서 사용하려면 RegisterStartupScript 혹은 RegisterClientScriptBlock 함수를 사용해야 함 사용법은 MSDN 참조(http://msdn.microsoft.com/kokr/library/system.web.ui.page.registerclientscript block.aspx) Artificial Intelligence Laboratory 구글 Weather API 구글에서 제공하는 날씨정보는 XML 형태로 제공 - http://www.google.co.kr/ig/api?weather=busan Artificial Intelligence Laboratory 9주차 과제 Google/ 네이버 검색 API를 이용한 검색페이지 + Google Weather API 기본 UI 구글 Weather API 라디오 버튼으로 선택할수 있으며 Google 을 선택하면 구글 API로 검색이 되며, 네이버를 선택하면 네이버 API 로 검색이 가능하게 한다. Artificial Intelligence Laboratory RadioButton 구글 검색/ 네이버 검색 선택을 위한 용도 RadioButtonList 로 구현 Selected ‘true’를 이용하여 초기 선택 버튼 설정 Artificial Intelligence Laboratory String.Format string 변수에 특정 format 적용 방법 {0}, {1}, … 등은 parameter 변수 순서 {0:D} – Decimal {0:F} – Fixed Point Artificial Intelligence Laboratory 구글 Weather API Weather API 는 페이지가 로드될때마다 실행되므로 Page_Load 함수에서 구현 한글 Encoding 문제가 발생하므로 아래와 같은 코드를 구현 추가 Artificial Intelligence Laboratory 구글 검색 API 구글 검색API 는 자바스크립트로 동작 아래그림과 같이 구글API 에서 제공하는 검색입력창이 생성되므 로, 이 폼을 분리할 필요가 있음 자바스크립트의 getElementById 로 동작하므로 html 코드에 <div id=“searchForm”> 과 같은 항목이 있어야함 searchControl 함수 실행 시 검색어를 받는 폼과 결과 폼을 분리 하여야 하므로 검색어를 받는 폼은 <input type=“hidden”id=“searchForm”> 과 같은식으로 사용 자세한 내용은 http://code.google.com/intl/ko/apis/ajaxsearch/documentation 참고 Javascript 함수 중 getElementById 참고 Artificial Intelligence Laboratory 구글 검색 API 대략적인 코드는 다음과 같음 Artificial Intelligence Laboratory 참고사이트 http://ultteky.egloos.com/10203768 RegisterClientScriptBlock 함수사용관련 http://dev.naver.com/openapi/apis/search/webkr 네이버 웹문서 API 사용 http://code.google.com/intl/ko/apis/ajaxsearch/doc umentation/ - 구글AJAX 검색 API 사용 http://blog.daum.net/akizora/7613497 구글 Weather API이용하기 Artificial Intelligence Laboratory