Really publishes the feeds
authorJaroslav Tulach <jtulach@netbeans.org>
Wed, 10 Nov 2010 00:15:47 +0100
changeset 221a08b9be14a
parent 1 93c350696ff6
child 3 ba411f9d13e5
Really publishes the feeds
.hgignore
pom.xml
src/main/java/cz/xelfi/feedbook/Main.java
     1.1 --- a/.hgignore	Tue Nov 09 23:52:40 2010 +0100
     1.2 +++ b/.hgignore	Wed Nov 10 00:15:47 2010 +0100
     1.3 @@ -3,3 +3,4 @@
     1.4  \.chg\..*$
     1.5  \.rej$
     1.6  \.conflict\~$
     1.7 +^target.*
     2.1 --- a/pom.xml	Tue Nov 09 23:52:40 2010 +0100
     2.2 +++ b/pom.xml	Wed Nov 10 00:15:47 2010 +0100
     2.3 @@ -38,5 +38,10 @@
     2.4        <artifactId>facebook-java-api</artifactId>
     2.5        <version>3.0.4</version>
     2.6      </dependency>
     2.7 +    <dependency>
     2.8 +      <groupId>net.java.dev.rome</groupId>
     2.9 +      <artifactId>rome</artifactId>
    2.10 +      <version>1.0.0</version>
    2.11 +    </dependency>
    2.12    </dependencies>
    2.13  </project>
     3.1 --- a/src/main/java/cz/xelfi/feedbook/Main.java	Tue Nov 09 23:52:40 2010 +0100
     3.2 +++ b/src/main/java/cz/xelfi/feedbook/Main.java	Wed Nov 10 00:15:47 2010 +0100
     3.3 @@ -40,12 +40,6 @@
     3.4          WireFeedInput rssInput = new WireFeedInput();
     3.5          URL rssUrl = new URL("http://blogs.apidesign.org/rss/");
     3.6          Channel rss = (Channel)rssInput.build(new InputSource(rssUrl.openStream()));;
     3.7 -        System.err.printf("stream from %s\n", rss.getUri());
     3.8 -        for (Object o : rss.getItems()) {
     3.9 -            Item item = (Item)o;
    3.10 -            
    3.11 -            System.err.printf("link: %s date: %s title: %s\n", item.getLink(), item.getPubDate(), item.getTitle());
    3.12 -        }
    3.13          
    3.14          Preferences prefs = Preferences.userNodeForPackage(Main.class);
    3.15          
    3.16 @@ -62,20 +56,21 @@
    3.17              break;
    3.18          }
    3.19          Long user = fb.users_getLoggedInUser();
    3.20 -        final FriendsGetResponse ret = fb.friends_get(user);
    3.21 -        final UsersGetInfoResponse info = fb.users_getInfo(ret.getUid(), Collections.<CharSequence>singleton("last_name"));
    3.22 -        final List<User> arr = info.getUser();
    3.23 -        System.out.println("friends: " + arr.size());
    3.24 -        for (int i = 0; i < arr.size(); i++) {
    3.25 -            System.out.println("  " + i + ". = " + arr.get(i).getLastName());
    3.26 -        }
    3.27          
    3.28 -        String url = "http://apidesign.org";
    3.29 -        String cmd = "Testing new application";
    3.30 -
    3.31          if (fb.users_hasAppPermission(Permission.SHARE_ITEM)) {
    3.32 -            Long ok = 1L; //fb.links_post(user, url, cmd);
    3.33 -            System.out.println("posted as " + ok);
    3.34 +            Preferences n = prefs.node("feeds");
    3.35 +            for (Object o : rss.getItems()) {
    3.36 +                Item item = (Item) o;
    3.37 +                String hex = Integer.toHexString(item.getLink().hashCode());
    3.38 +                if (n.getLong(hex, -1L) != -1L) {
    3.39 +                    continue;
    3.40 +                }
    3.41 +                System.err.printf("link: %s date: %s title: %s\n", item.getLink(), item.getPubDate(), item.getTitle());
    3.42 +                Long ok = fb.links_post(user, item.getLink(), item.getTitle());
    3.43 +                System.out.println("posted as " + ok);
    3.44 +                n.putLong(hex, ok);
    3.45 +                n.put(hex + ".url", item.getLink());
    3.46 +            }
    3.47          } else {
    3.48              System.out.println("No permission to share links");
    3.49          }