开发者

Using Facebook API on an Java App OUTSIDE Facebook

开发者 https://www.devze.com 2022-12-20 10:05 出处:网络
I want to access Facebook info from a Java Application that is not intended to run on Facebook. I just want to be able to get and delete comments on a desktop Application but I don\'t know where to st

I want to access Facebook info from a Java Application that is not intended to run on Facebook. I just want to be able to get and delete comments on a desktop Application but I don't know where to start.

The Facebook developers page says something about a REST API, but all the examples on the documentation are written on PHP. Also, there is a lot of information about Facebook Connect, but that seems to be only useful for applications that want to show Facebook widgets.

I just want to get direct access to the info, posts, comments, etc, ...

Is there a REST API to access Facebook ? Wheres the docume开发者_JAVA百科ntation/examples/tutorial/etc?

Somebody knows where to start, some good documentation/tutorial, etc. Somebody to point me on the right direction please.

Thanks!!


Java Facebook API: http://code.google.com/p/facebook-java-api/


The new REST API documentation can be found here: http://developers.facebook.com/docs/reference/api/

If you're interested in a Java library which uses this REST API see RestFB here: http://restfb.com/


You can easily use scribe : https://github.com/fernandezpablo85/scribe-java. It has a neat approach. It looks like :

interface FACEBOOK {
static final String APP_ID = "xxxxxxx";
static final String API_KEY = "xxxxxxx";
static final String APP_SECRET = "xxxxxxx";
static final String ACCESS_TOKEN = "xxxxxxx";
static final String PROTECTED_RESOURCE_URL = "https://graph.facebook.com/PROFILE ID/feed";}

OAuthService facebookService = new ServiceBuilder().provider(FacebookApi.class).apiKey(FACEBOOK.API_KEY).apiSecret(FACEBOOK.APP_SECRET).build();
    OAuthRequest facebookRequest = new OAuthRequest(Verb.POST, FACEBOOK.PROTECTED_RESOURCE_URL);
    Token facebookAccessToken = new Token(FACEBOOK.ACCESS_TOKEN, FACEBOOK.APP_SECRET);
    facebookRequest.addQuerystringParameter("message", status);
    facebookService.signRequest( facebookAccessToken , facebookRequest);
    facebookRequest.send();
0

精彩评论

暂无评论...
验证码 换一张
取 消