How To Post a Sale to a Facebook Group using Facebook4J?

285 views Asked by At

So I'm working on an application that would post something that I want to sell to all of the facebook groups that I'm a part of. I've sort of familiarized myself with Facebook4J already (I can log in, post status, etc....), but I don't know how to post a sale. I can't find the answer anywhere, so I'd thought I'd ask!

This is my code so far, though I don't think it's very relevant to my question..

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

There are 0 answers