7

我徒劳地寻找了一个很好的例子或起点来编写一个基于 java 的 facebook 应用程序......我希望这里有人会知道一个。同样,我听说 facebook 将不再支持他们的 java API,这是真的吗?如果是,这是否意味着我们不应该再使用 java 来编写 facebook 应用程序?

4

6 回答 6

6

根据他们的开发者维基,Facebook 于 2008 年 5 月 5 日停止支持官方 Java API 。

这绝不意味着您不应该再使用 Java 来编写 FB 应用程序。wiki 上列出了几种可供选择的 Java 方法。

您可能还想检查这个项目;然而,它只是在几天前才出来,所以 YMMV。

于 2008-09-15T12:50:04.843 回答
6

有一个社区项目旨在使 Facebook Java API 保持最新,使用旧的官方 Facebook 代码作为起点。

您可以在此处找到它以及入门指南和一些示例代码。

于 2008-09-15T12:55:39.900 回答
2

我使用 facebook java api编写了一个示例 它使用 FacebookXmlRestClient 来发出客户端请求并打印所有用户信息 http://programmaremobile.blogspot.com/2009/01/facebook-java-apieng.html

于 2009-02-13T12:11:11.037 回答
1

BatchFB 提供了一个现代 Java API,让您可以轻松地将 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();
于 2011-09-14T04:39:49.190 回答
0

You might want to try Spring Social. It might be limited in terms of Facebook features, but lets you also connect to Twitter, LinkedIn, TripIt, GitHub, and Gowalla.

The other side of things is that as Facebook adds features some of the old API's might break, so using a simpler pure FB api (that you can update when things don't work) might be a good idea.

于 2011-08-24T21:59:11.663 回答
0

This tutorial will literally step you through everything you need to do: http://ocpsoft.org/opensource/creating-a-facebook-app-setup-and-tool-installation/

It comes in 3 parts. The other 2 are linked from there.

于 2012-04-05T00:02:39.560 回答