Example usage for org.springframework.social.facebook.api Facebook post

List of usage examples for org.springframework.social.facebook.api Facebook post

Introduction

In this page you can find the example usage for org.springframework.social.facebook.api Facebook post.

Prototype

void post(String objectId, String connectionName, MultiValueMap<String, Object> data);

Source Link

Document

Publishes data to an object's connection.

Usage

From source file:com.naver.template.social.SocialPostBO.java

public void postToFacebook(String userId) {
    Facebook facebook = simpleSocialConnectionFactory.getFacebook(userId);

    String imageUrl = "http://cfile9.uf.tistory.com/image/1771223E4E3EAE20032F8B";
    String linkUrl = "";
    String linkName = "?";
    String caption = "lovepin.it";
    String description = "? blah blah";
    String actions = "[{ name: 'Get the LOVEPIN App', link: 'http://lovepin.it/apps' }]";

    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.set("picture", imageUrl);
    map.set("link", linkUrl);
    map.set("name", linkName);
    map.set("caption", caption);
    map.set("description", description);
    map.set("actions", actions);

    String providerUserId = simpleSocialConnectionFactory.getConnectionRepository(userId)
            .getPrimaryConnection(Facebook.class).getKey().getProviderUserId();

    try {//  www.java2  s. c om
        facebook.post(providerUserId, "feed", map);
    } catch (NotAuthorizedException ex) {
        //
    } catch (OperationNotPermittedException ex) {
        //
    } catch (ApiException ex) {
        //
    } catch (ResourceAccessException ex) {
        //
    }
}