[Jiemamy-notify:2772] commit [3696] bitlyのAPIアカウント情報をDatastoreから拾うようにした。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 10月 4日 (日) 15:47:53 JST


Revision: 3696
          http://sourceforge.jp/projects/jiemamy/svn/view?view=rev&revision=3696
Author:   shin1
Date:     2009-10-04 15:47:53 +0900 (Sun, 04 Oct 2009)

Log Message:
-----------
bitlyのAPIアカウント情報をDatastoreから拾うようにした。

Modified Paths:
--------------
    sandbox/jiemamy-feeds/src/main/java/com/shin1ogawa/util/BitlyUtil.java

Modified: sandbox/jiemamy-feeds/src/main/java/com/shin1ogawa/util/BitlyUtil.java
===================================================================
--- sandbox/jiemamy-feeds/src/main/java/com/shin1ogawa/util/BitlyUtil.java	2009-10-04 06:20:37 UTC (rev 3695)
+++ sandbox/jiemamy-feeds/src/main/java/com/shin1ogawa/util/BitlyUtil.java	2009-10-04 06:47:53 UTC (rev 3696)
@@ -5,6 +5,7 @@
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.util.logging.Logger;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -29,18 +30,17 @@
 
 	static final String FORMAT = "http://api.bit.ly/shorten?version=2.0.1&login=%s&apiKey=%s&longUrl=%s&format=xml";
 
-	static final String DEFAULT_LOGIN = "shin1ogawa";
 
-	static final String DEFAULT_APIKEY = "R_5b082ea6affad0e4c7ed56e031d72549";
-
 	private BitlyUtil() {
 	}
 
 	public static BitlyVO shorten(String longUrl) throws MalformedURLException, IOException,
 			XPathExpressionException, ParserConfigurationException, SAXException {
 		URLFetchService service = URLFetchServiceFactory.getURLFetchService();
-		HTTPResponse response = service.fetch(new URL(String.format(FORMAT, DEFAULT_LOGIN,
-				DEFAULT_APIKEY, longUrl)));
+		String login = (String) ApplicationSettingUtil.getSettingValue("bitly-user");
+		String apiKey = (String) ApplicationSettingUtil.getSettingValue("bitly-apikey");
+		HTTPResponse response = service.fetch(new URL(String.format(FORMAT, login,
+				apiKey, URLEncoder.encode(longUrl, "utf-8"))));
 		if (response.getResponseCode() != HttpURLConnection.HTTP_OK) {
 			throw new RuntimeException(longUrl + " response code=" + response.getResponseCode());
 		}




Jiemamy-notify メーリングリストの案内
Back to archive index