如何使用Facebook4J向Facebook群发布销售?

时间:2016-02-10 18:40:29

标签: java eclipse facebook social-networking facebook4j

所以我正在开发一个应用程序,可以发布我想卖给我所属的所有facebook组的东西。我已经熟悉了Facebook4J(我可以登录,发布状态等等),但我不知道如何发布销售。我无法在任何地方找到答案,所以我想我会问!

这是我的代码到目前为止,虽然我不认为这与我的问题非常相关..

import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.auth.AccessToken;
import facebook4j.auth.OAuthAuthorization;
import facebook4j.auth.OAuthSupport;
import facebook4j.conf.Configuration;
import facebook4j.conf.ConfigurationBuilder;
import java.net.MalformedURLException;
import java.net.URL;

import facebook4j.*;

public class facebook {


public static void main(String[] args) {

    String appId = "MY_APPID(don't want to share this info)";

    String appSecret = "MY_APPSECRET(also don't want to share)";

    Facebook facebook = new FacebookFactory().getInstance();

    facebook.setOAuthAppId(appId, appSecret);


    String accessToken = "ACCESSTOKEN(also don't want to share)";
    AccessToken at = new AccessToken(accessToken);
    // Set access token.
    facebook.setOAuthAccessToken(at);

    /*try {
        facebook.postStatusMessage("Hello World from Facebook4J.");
    } catch (FacebookException e) {
        e.printStackTrace();
    }*/
    PostUpdate post = null;
    try {
        post = new PostUpdate(new URL("http://facebook4j.org"))
                .picture(new URL("http://facebook4j.org/images/hero.png"))
                .name("Facebook4J - A Java library for the Facebook Graph API")
                .caption("facebook4j.org")
                .description("Facebook4J is a Java library for the Facebook Graph API.");
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
try {
facebook.postFeed(post);
} catch (FacebookException e) {
// TODO Auto-generated catch block
e.printStackTrace();
  }
 }

}

0 个答案:

没有答案