Recommended
PDF
옛날 웹 개발자가 잠깐 맛본 Vue.js 소개
PPTX
PPTX
PDF
PPTX
PDF
PDF
PDF
PPTX
PPTX
제2회 한글형태소분석기 기술 세니마 발표(solr 활용 입문) by 김지훈
PPTX
UML distilled 1장 스터디 발표 자료
PPTX
PPTX
5-4. html5 offline and storage
PPTX
유니티 REST API를 사용한 파이어 베이스의 데이터 베이스 사용.
PDF
GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출
PPTX
PDF
GKAC 2015 Apr. - Android Looper
PDF
Undertow RequestBufferingHandler 소개
PDF
PPTX
PPTX
Startup JavaScript 8 - NPM, Express.JS
PDF
PDF
자바모델 클래스에 날개를달자_롬복(Lombok)
PDF
[TECHCON 2019: MOBILE - Android]2.예제에서는 알려주지 않는 Model 이야기
PDF
[11]Android DataBinding : 기초에서 고급까지
PDF
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
KEY
PPTX
ODP
PPTX
Using The Legislative Process to Further Your Business
More Related Content
PDF
옛날 웹 개발자가 잠깐 맛본 Vue.js 소개
PPTX
PPTX
PDF
PPTX
PDF
PDF
PDF
What's hot
PPTX
PPTX
제2회 한글형태소분석기 기술 세니마 발표(solr 활용 입문) by 김지훈
PPTX
UML distilled 1장 스터디 발표 자료
PPTX
PPTX
5-4. html5 offline and storage
PPTX
유니티 REST API를 사용한 파이어 베이스의 데이터 베이스 사용.
PDF
GKAC 2015 Apr. - Battery, 안드로이드를 위한 쉬운 웹 API 호출
PPTX
PDF
GKAC 2015 Apr. - Android Looper
PDF
Undertow RequestBufferingHandler 소개
PDF
PPTX
PPTX
Startup JavaScript 8 - NPM, Express.JS
PDF
PDF
자바모델 클래스에 날개를달자_롬복(Lombok)
PDF
[TECHCON 2019: MOBILE - Android]2.예제에서는 알려주지 않는 Model 이야기
PDF
[11]Android DataBinding : 기초에서 고급까지
PDF
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
KEY
PPTX
Viewers also liked
ODP
PPTX
Using The Legislative Process to Further Your Business
PDF
PPTX
Pricing for an internet marketing campaign
PDF
PDF
Tizen 2.0 alpha でサポートされなかった native api icebreak
PPS
PPTX
PPT
PPTX
PPTX
PDF
PPTX
PPT
PPTX
PPTX
PDF
Knight Mischief Entertainment
PDF
Building Distributed Systems Using Helix
PPT
PPTX
Similar to Naver api for android
PDF
PDF
[NEXT] Android 개발 경험 프로젝트 4일차 (Networking)
PDF
R.java가 사라졌어요 어떻하죠?:Aquery라이브러리와 안드로이드 개발팁
PPTX
2Naver Open Android API Translation At DCamp
PDF
2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디
PPTX
PDF
[D2 CAMPUS] 안드로이드 오픈소스 스터디자료 - Http Request
PDF
Naver 오픈api-마이그레이션가이드 20160913-리뷰
PPTX
Ksug 세미나 (윤성준) (20121208)
PDF
[NEXT] Android 개발 경험 프로젝트 3일차 (Database)
PDF
PPTX
PDF
PPT
PDF
자바 웹 개발 시작하기 (3주차 : 스프링 웹 개발)
PDF
[Hello world 오픈세미나]open api client개발
PDF
PDF
PDF
1.Create Project Sunshine - 시온고등학교 안드로이드 스터디
PDF
Naver api for android 1. 2. 네이버 오픈API를 활용한 백과사전 앱
목표 : 네이버 오픈API를 활용하여 백과사전 검색 Android App을 만든다.
Step 1
네이버 개발자센터 등록및 키 발급
http://dev.naver.com/
3. 4. 5. 6. 키 등록/관리 -> 검색API -> 키추가
검색API 사용을 위한 키(key)는 바로 발급이 된다.
하루에 사용할수 있는 쿼리의 제한이 있다. 하루25000쿼리
7. 네이버API 발급키 이용한 TEST쿼리
- 샘플 URL
'독도'를 검색할 경우 :
http://openapi.naver.com/search?key= 14a5a7f022650cc46f4a20867abb4fde
&query=%EB%8F%85%EB%8F%84&target=encyc&start=1&display=10
8. 네이버API 쿼리 결과 코드
<?xml version="1.0" encoding="UTF-8" ?>
- <rss version="2.0">
- <channel>
<title>Naver Open API - encyc ::'독도'</title>
<link>http://search.naver.com</link>
<description>Naver Search Result</description>
<lastBuildDate>Mon, 20 Jul 2009 13:11:39 +0900</lastBuildDate>
<total>189</total>
<start>1</start>
<display>10</display>
- <item>
<title><b>독도</b></title>
<link>http://openapi.naver.com/l?AAADXHsQqAIBRA0a95jmJq5uJQlP8R+kKH1MQC/76W4A7ntl7QYHLdkTt6
IyepOLlurN3AtoC2oMcfkoSKhwmtFRAzcPs1MEbT/mClLp//hwTC+uyiB7FKrUb1Art54r9nAAAA</link>
<description>경상북도 울릉군 울릉읍 <b>독도</b>리에 있는 섬. | 위치 : 경상북도 울릉군 울릉읍 <b>독도</b>리
1~96 번지 | 경위도 : 동도(동경 131도 52분 10.4초, 북위 37도 14분 26.8초), 서도(동경 131도 51분 54.6초, 북위 37도 14분 30.6초) |
면적 : 187,554㎡(동...</description>
<thumbnail>http://sstatic.naver.com/search/100_thumb_nx3/7/1304007.jpg</thumbnail>
</item>
- <item>
<title><b>독도</b></title>
<link>http://openapi.naver.com/l?AAACupLEi1Tc1LrkxWK81MsTUxNzEzUissTS2qtFV1dVK1cFO1MIUxTNQyi
lLTbDNKSgpUjR1VjdyAKDtfrzwzO7MgNSUzUS+/KB0oBOKDJU2B+oxMLUAsoCEoXBMAOybjnngAAAA=</link>
<description> <b>독도</b>(獨島)는 동해 가운데, 대한민국울릉도 동남쪽에 있는 섬으로, 동도와 서도를 포함하여 총
91개의 크고 작은 섬들로 이루어져 있다.[1][2] 해방 이후 현재까지 대한민국이 실효 지배하고 있으며, 행정구역 상으
로 ...</description>
<thumbnail />
</item>
개별 검색 결과이며, title, link, description, thumbnail 을 포함합니다
9. 10. 11. 네이버API 백과사전 앱 실습
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<EditText android:id="@+id/input01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:hint="Enter URL String ..."
android:textSize="14sp" />
<Button
android:id="@+id/requestBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Request"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/txtMsg" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#ff99ccee"
android:textColor="#ff0000ff" android:textSize="12sp" />
</ScrollView>
</LinearLayout>
</RelativeLayout>
12. 네이버API 백과사전 앱 실습
Step 3
MainActivity.java coding
public static String defaultUrl = "http://openapi.naver.com/search";
static final String mykeycode =“****************************";
final EditText input01 = (EditText)findViewById(R.id.input01);
input01.setText("apple");
final TextView txtMsg = (TextView) findViewById(R.id.txtMsg);
Button requestBtn = (Button) findViewById(R.id.requestBtn);
requestBtn.setOnClickListener(new OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
String tempquery = input01.getText().toString();
String makeURL="";
makeURL = String.format(defaultUrl + "?key=%s&query=%s&target=encyc&start=1&display=10",
mykeycode ,
URLEncoder.encode(tempquery));
txtMsg.setText(makeURL);
String output = request(makeURL);
txtMsg.setText(output);
}
});
13. 네이버API 백과사전 앱 실습
private String request(String urlStr) {
StringBuilder output = new StringBuilder();
try {
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
if (conn != null) {
conn.setConnectTimeout(10000);
conn.setRequestMethod("GET");
conn.setDoInput(true);
conn.setDoOutput(true);
int resCode = conn.getResponseCode();
if (resCode == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())) ;
String line = null;
while(true) {
line = reader.readLine();
if (line == null) {
break;
}
output.append(line + "n");
}
reader.close();
conn.disconnect();
}
}
} catch(Exception ex) {
Log.e("SampleHTTP", "Exception in processing response.", ex);
}
return output.toString();
}
14. 15. 네이버API 백과사전 앱 실습
Step 4
DOM parser 를 이용하여 파싱된 데이터 보여주기
public static String defaultUrl = "http://openapi.naver.com/search";
static final String mykeycode =“******************************";
public static String parsingresult="";
String xml = output.toString();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream istream = new ByteArrayInputStream(xml.getBytes("utf-8"));
Document doc = builder.parse(istream);
Element order = doc.getDocumentElement(); //루트 엘리먼트를 구한다.
NodeList items = order.getElementsByTagName("title");
16. 네이버API 백과사전 앱 실습
private String request(String urlStr) {
StringBuilder output = new StringBuilder();
try {
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
if (conn != null) {
conn.setConnectTimeout(10000);
conn.setRequestMethod("GET");
conn.setDoInput(true);
conn.setDoOutput(true);
int resCode = conn.getResponseCode();
if (resCode == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())) ;
String line = null;
while(true) {
line = reader.readLine();
if (line == null) {
break;
}
output.append(line + "n");
}
reader.close();
conn.disconnect();
}
}
String xml = output.toString();
17. 네이버API 백과사전 앱 실습
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream istream = new ByteArrayInputStream(xml.getBytes("utf-8"));
Document doc = builder.parse(istream);
Element order = doc.getDocumentElement();// 유일한 루트 엘리먼트를 구한다.
NodeList items = order.getElementsByTagName("title");
String Result = "";
for (int i = 0; i < items.getLength();i++) {
NodeList items2 = order.getElementsByTagName("description");
Node item2 = items2.item(i);
Node text2 = item2.getFirstChild();
String ItemName2 = text2.getNodeValue();
Node item = items.item(i);
Node text = item.getFirstChild();
String ItemName = text.getNodeValue();
if(i!=0)
{
Result += ItemName + " : " + ItemName2;
}
Result += "nn";
}
parsingresult = Result;
} catch(Exception ex) {
Log.e("SampleHTTP", "Exception in processing response.", ex);
}
return parsingresult;
}
18.