# HG changeset patch # User Jaroslav Tulach # Date 1289332876 -3600 # Node ID 258dc96b16364e58a6ce63fb3983a6881f5e0e27 Initial version of a project that can copy my RSS feed to facebook diff -r 000000000000 -r 258dc96b1636 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Tue Nov 09 21:01:16 2010 +0100 @@ -0,0 +1,5 @@ +\.orig$ +\.orig\..*$ +\.chg\..*$ +\.rej$ +\.conflict\~$ diff -r 000000000000 -r 258dc96b1636 pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pom.xml Tue Nov 09 21:01:16 2010 +0100 @@ -0,0 +1,42 @@ + + 4.0.0 + + cz.xelfi + Feedbook + 0.1 + jar + + Feedbook + http://maven.apache.org + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + com.google.code.facebookapi + facebook-java-api + 3.0.4 + + + diff -r 000000000000 -r 258dc96b1636 src/main/java/cz/xelfi/feedbook/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/cz/xelfi/feedbook/Main.java Tue Nov 09 21:01:16 2010 +0100 @@ -0,0 +1,57 @@ +package cz.xelfi.feedbook; + +import com.google.code.facebookapi.FacebookJaxbRestClient; +import com.google.code.facebookapi.Permission; +import com.google.code.facebookapi.schema.FriendsGetResponse; +import com.google.code.facebookapi.schema.User; +import com.google.code.facebookapi.schema.UsersGetInfoResponse; +import java.net.URI; +import java.util.Collections; +import java.util.List; + +public class Main { + private static final String APP_KEY = "ecdbd5dbacc168f9edfe470ccd7e401b"; + private static final String APP_SEC = "22e3165366e958a6e049e1e0c1d30105"; + + public static void main( String[] args) throws Exception { + FacebookJaxbRestClient login = new FacebookJaxbRestClient(APP_KEY, APP_SEC); + final String token = login.auth_createToken(); + URI u = new URI("http://www.facebook.com/login.php?api_key=" + APP_KEY + "&auth_token=" + token); + Runtime.getRuntime().exec("xdg-open " + u); + /* + InputStream is = u.toURL().openStream(); + for (;;) { + int ch = is.read(); + if (ch == -1) { + break; + } + System.out.write(ch); + } + */ + //Desktop.getDesktop().browse(u); + System.out.println("Visit the browser and press enter..."); + System.in.read(); + + final String session = login.auth_getSession(token, true); + + FacebookJaxbRestClient fb = new FacebookJaxbRestClient(APP_KEY, APP_SEC, session); + Long user = fb.users_getLoggedInUser(); + final FriendsGetResponse ret = fb.friends_get(user); + final UsersGetInfoResponse info = fb.users_getInfo(ret.getUid(), Collections.singleton("last_name")); + final List arr = info.getUser(); + System.out.println("friends: " + arr.size()); + for (int i = 0; i < arr.size(); i++) { + System.out.println(" " + i + ". = " + arr.get(i).getLastName()); + } + + String url = "http://apidesign.org"; + String cmd = "Testing new application"; + + if (fb.users_hasAppPermission(Permission.SHARE_ITEM)) { + Long ok = fb.links_post(user, url, cmd); + System.out.println("posted as " + ok); + } else { + System.out.println("No permission to share links"); + } + } +}