我一直在寻找一个好的例子或起点来编写基于Java的Facebook应用程序,但一直没有找到...希望这里有人知道。此外,我听说Facebook将不再支持他们的Java API,这是真的吗?如果是,那么我们是否应该停止使用Java来编写Facebook应用程序?
http://code.google.com/p/batchfb/
这是从主页面获取的一个示例,展示了您可以在单个FB请求中有效执行的操作:/** You write your own Jackson user mapping for the pieces you care about */
public class User {
long uid;
@JsonProperty("first_name") String firstName;
String pic_square;
String timezone;
}
Batcher batcher = new FacebookBatcher(accessToken);
Later<User> me = batcher.graph("me", User.class);
Later<User> mark = batcher.graph("markzuckerberg", User.class);
Later<List<User>> myFriends = batcher.query(
"SELECT uid, first_name, pic_square FROM user WHERE uid IN" +
"(SELECT uid2 FROM friend WHERE uid1 = " + myId + ")", User.class);
Later<User> bob = batcher.queryFirst("SELECT timezone FROM user WHERE uid = " + bobsId, User.class);
PagedLater<Post> feed = batcher.paged("me/feed", Post.class);
// No calls to Facebook have been made yet. The following get() will execute the
// whole batch as a single Facebook call.
String timezone = bob.get().timezone;
// You can just get simple values forcing immediate execution of the batch at any time.
User ivan = batcher.graph("ivan", User.class).get();
这个教程将逐步指导您完成所有必要的步骤:http://ocpsoft.org/opensource/creating-a-facebook-app-setup-and-tool-installation/
它分为三个部分,另外两个部分在那里链接。