user3224244
user3224244

Reputation: 11

How to publish a post using Facebook4J so that others can see it

I use this code to publish a post on my Facebook wall from Java:

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

However, there is a problem: only I can see this post, my friends cannot. How can it be visible to my friends?

Upvotes: 1

Views: 2550

Answers (2)

Roman Kazanovskyi
Roman Kazanovskyi

Reputation: 3599

where in is InputStream your photo

Media media = new Media("", in);

PhotoUpdate photoUpdate = new PhotoUpdate(media);

postId = facebook.postPhoto(photoUpdate);

Upvotes: 1

roundrop
roundrop

Reputation: 188

With postStatusMessage() method, you publish a post using your default privacy setting.
Try to use postFeed() method with privacy parameter.

To post to all friends example:

PrivacyParameter privacy = new PrivacyBuilder().setValue(PrivacyType.ALL_FRIENDS).build();
PostUpdate postUpdate = 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. This library provides the ease of use like Twitter4J. Facebook4J is an unofficial library.")
    .privacy(privacy);
String postId = facebook.postFeed(postUpdate);

Upvotes: 5

Related Questions