使用Facebook4j在墙上张贴

时间:2016-01-18 06:18:56

标签: facebook4j

我是Facebook4j的新手,我正在寻找一种使用它发布消息的方法。我刚刚在互联网上学到了很少的编码。请有人帮助我。

这就是我所做的:

import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.conf.Configuration;
import facebook4j.conf.ConfigurationBuilder;

public class post {

public static void main(String[] args) 
        throws FacebookException 
{ 
    // Create conf builder and set authorization and access keys 
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
    configurationBuilder.setDebugEnabled(true); 
    configurationBuilder.setOAuthAppId("xxxx");
    configurationBuilder.setOAuthAppSecret("xxxx");
    configurationBuilder.setOAuthAccessToken("xxxx");
    configurationBuilder .setOAuthPermissions("email, publish_stream, id, name, first_name, last_name, read_stream , generic");
    configurationBuilder.setUseSSL(true);


    // Create configuration and get Facebook instance 
    Configuration configuration = configurationBuilder.build(); 
    FacebookFactory ff = new FacebookFactory(configuration);
    Facebook Facebook = ff.getInstance(); 


    Facebook.postStatusMessage("Hello World from Facebook4J.");


}

    }

那么,接下来我需要做什么?

1 个答案:

答案 0 :(得分:0)

您是否已在https://developers.facebook.com上创建并授权了您的应用?

这实际上是第一步。