# HG changeset patch # User Jaroslav Tulach # Date 1289427826 -3600 # Node ID a2bb3db4c9b6e671ae3d0915b74b211bf3533da2 # Parent cb3f8481a580f9e31d239e0a4cba3e7319b14123 Don't hardcode the application key, secret and RSS URL diff -r cb3f8481a580 -r a2bb3db4c9b6 src/main/java/cz/xelfi/feedbook/Main.java --- a/src/main/java/cz/xelfi/feedbook/Main.java Wed Nov 10 17:48:58 2010 +0100 +++ b/src/main/java/cz/xelfi/feedbook/Main.java Wed Nov 10 23:23:46 2010 +0100 @@ -15,8 +15,9 @@ import org.xml.sax.InputSource; public class Main { - private static final String APP_KEY = "ecdbd5dbacc168f9edfe470ccd7e401b"; - private static final String APP_SEC = "22e3165366e958a6e049e1e0c1d30105"; + private static String APP_KEY; + private static String APP_SEC; + private static String APP_FEED; private static String login() throws IOException, FacebookException, URISyntaxException { @@ -40,11 +41,32 @@ } public static void main( String[] args) throws Exception { + Preferences prefs = Preferences.userNodeForPackage(Main.class); + if (args.length == 3) { + prefs.put("id", args[0]); + prefs.put("secret", args[1]); + prefs.put("feed", args[2]); + } else { + if (args.length != 0) { + usage(); + return; + } + } + + + APP_KEY = prefs.get("id", null); + APP_SEC = prefs.get("secret", null); + APP_FEED = prefs.get("feed", null); + + if (APP_FEED == null || APP_SEC == null || APP_KEY == null) { + usage(); + return; + } + WireFeedInput rssInput = new WireFeedInput(); - URL rssUrl = new URL("http://blogs.apidesign.org/rss/"); + URL rssUrl = new URL(APP_FEED); Channel rss = (Channel)rssInput.build(new InputSource(rssUrl.openStream()));; - Preferences prefs = Preferences.userNodeForPackage(Main.class); FacebookJaxbRestClient fb; Long user; @@ -90,4 +112,11 @@ } System.out.println("Published " + cnt + " feed item(s)"); } + + private static void usage() { + System.out.println("Invoke with three parameters: " + + " " + + ""); + } }