mccarthyj
mccarthyj

Reputation: 949

Sharing a post on facebook page using RestFB

I'm using RestFB to automatically post to a Facebook page (not my personal page, an entertainment news page I've set up) I took the code example from here: how do i share a post on facebook using restfb but it's not working for certain posts. Can you tell me what I'm doing wrong?

public class FacebookHelper {

    private static final DefaultFacebookClient facebookClient = new DefaultFacebookClient("<access token>", Version.VERSION_2_5);
    private static final Page page = facebookClient.fetchObject("<page id>", Page.class);

    public static void updateStatus(String message, String link) {

        facebookClient.publish("<page id>/feed", FacebookType.class, Parameter.with("message", message), Parameter.with("link", link));

    }

    public static void main(String[] args) {

        // not working - only message appearing in status
        FacebookHelper.updateStatus("RestFB test2", "https://www.facebook.com/becky.ofarrell.5/videos/1123590904340401/");
        // working correctly - message and photo in status
        FacebookHelper.updateStatus("RestFB test3", "https://www.facebook.com/mullingar.parish/photos/a.341019462759743.1073741826.341019429426413/431550013706687/?type=3");
        // working correctly - message and video in status
        FacebookHelper.updateStatus("RestFB test4", "https://www.facebook.com/RuairiOgclg/videos/574647342685093/");

    }

}

All links are public, so I don't think I'm breaking any privacy issues about using them here For the example that's failing, I can share it manually without any problems

Upvotes: 0

Views: 966

Answers (1)

mccarthyj
mccarthyj

Reputation: 949

The issue seems to have resolved itself, and posts are now being shared correctly. One theory is that the posts that failed to share were created before the access token I was using. Either way, it's not an issue any more

Upvotes: 0

Related Questions