[CODE] /* * @File Name : EGLOOSRpcClient.java * @Author : 윤주선 , ologist * @Date : 2006. 1. 13. * @Copyright : Copyright ⓒ XXX Corp. All Rights Reserved. */ package com.XXX.common.xmlrpc.client; import java.io.IOException; import java.net.URL; import java.util.Hashtable; import java.util.StringTokenizer; import java.util.Vector; import org.apache.xmlrpc.XmlRpcClient; import org.apache.xmlrpc.XmlRpcException; public class EGLOOSRpcClient { public EGLOOSRpcClient() { super(); } // The location of our server. private final static String server_url = "http://rpc.egloos.com/rpc1"; public static void main (String [] args) { try { long start = System.currentTimeMillis(); URL url = new URL(server_url); XmlRpcClient server = new XmlRpcClient(url); //insertPost(server); getPost(server); long end = System.currentTimeMillis(); System.out.println("[MAIN] RUNNING TIME : " + (end - start)/1000f+ " secs"); }catch (Exception exception) { if (exception instanceof XmlRpcException) { System.err.println("[EGLOOSRpcClient ] Exception closing URLConnection"); }else if (exception instanceof IOException) { System.err.println("[EGLOOSRpcClient ] Server returned HTTP response code: 500 for URL: http://rpc.egloos.com/rpc1"); } System.err.println("EGLOOSRpcClient : " + exception.toString()); } } public static void insertPost(XmlRpcClient server) throws XmlRpcException, IOException{ String category = "[lab] IT"; String subject = "Posting with MetaWeblog API!!"; String content = "본문 테스트!!"; content = "" + content; Vector params = new Vector(); params.add("ologist"); params.add("ologist"); params.add("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); Hashtable struct = new Hashtable(); struct.put("title", subject); struct.put("description", content ); //struct.put( "dateCreated", "20050716T19:20:30" ); Vector categories = new Vector(); if (category != null) { StringTokenizer tok = new StringTokenizer(category, ","); while (tok.hasMoreTokens()) { categories.add(tok.nextToken().trim()); } } struct.put("categories", categories); params.add(struct); params.add(Boolean.TRUE); String postId = (String) server.execute("metaWeblog.newPost", params); System.out.println("value: " + postId); } public static Hashtable getPost(XmlRpcClient server) throws XmlRpcException, IOException{ Vector params = new Vector(); params.addElement(new String("1220385")); params.addElement(new String("ologist")); params.addElement(new String("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); Hashtable value = (Hashtable) server.execute("metaWeblog.getPost", params); return value; } } [/CODE]


간단하게 자바로 이글루스API중에 하나인 metaWeblog API를 이용해서 구현한 코드이다.
가장 기본적인 코드로 구성을 했기때문에 어렵지 않을것이다.
Posted by ologist
 TAG

블로그 이미지
ologist

공지사항

Yesterday221
Today25
Total34,406

달력

 « |  » 2012.02
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

최근에 받은 트랙백

글 보관함