restfb publish

restfb publish


message

FacebookType publishMessageResponse = facebookClient.publish("me/feed",
                        FacebookType.class, Parameter.with("message", "hello test"));
System.out.println("Published message ID: " + publishMessageResponse.getId());

photo from local

FacebookType publishPhotoResponse = facebookClient.publish("me/photos", FacebookType.class,
                        BinaryAttachment.with("icon.jpg", new FileInputStream("c:\\icon.jpg")),
                        Parameter.with("message", "photo post"));

photo from url

InputStream inputpic = new URL("http://www.url.com/jpg.jpg").openStream();
                FacebookType publishPhotoResponse = facebookClient.publish("me/photos", FacebookType.class,
                        BinaryAttachment.with("icon.jpg", inputpic), Parameter.with("message", "photo post"));

check in

Map<String, String> coordinates = new HashMap<String, String>();
coordinates.put("latitude", "37.06");
coordinates.put("longitude", "-95.67");
                           
FacebookType publishCheckinResponse = facebookClient.publish("me/checkins",
FacebookType.class, Parameter.with("message", "I'm here!"),
Parameter.with("coordinates", coordinates), Parameter.with("place", 1234));
System.out.println("Published checkin ID: " + publishCheckinResponse.getId());

reference:
http://restfb.com/#publishing

留言

這個網誌中的熱門文章

Java Servlet MVC web app

JavaMail透過Gmail寄信發生AuthenticationFailedException錯誤