SHANib
SHANib

Reputation: 718

Spring MVC Mobile Web - Social Sharing

In a Spring MVC mobile web application i have a requirement to post a custom messgage to social networking sites (Facebbok, linkedIN, Twitter, Google Plus).

ie If the user purchase a product he can share a predefined message "I purchased the product #134" like that.

First i thought of using simple javascript for sharing but it behaves differently in different mobiles and alse not able to post the predefined message. Another option i found is using spring-social.

Can any body suggest me any alternatives or best method to achieve this.

Any help will be appreciated.

Upvotes: 0

Views: 144

Answers (1)

Craig Walls
Craig Walls

Reputation: 2080

It sounds like your question is "Can Spring Social be used to post custom messages to a user's feed? Or can someone suggest alternatives?"

Addressing the first part of that question, yes Spring Social can do this. The specifics of which vary slightly from social API to social API, but in general you'd inject the API binding into the controller where you handle the purchase of a product and at purchase time use that API binding to post the message.

The gotcha, however, is that the user must authorize your application to post stuff. You can't just arbitrarily post messages to any API without the user's permission. Therefore, prior to that purchase being completed, your app will need to obtain a connection (a Spring Social concept that captures that permission and an access token that represents the permission) by redirecting the user to the FB/Twitter/LinkedIn/etc to prompt the user for permission. Spring Social's ConnectController exists to handle that redirect and to obtain the connection for you.

If you've not already had a look, look at https://github.com/spring-projects/spring-social-samples where I have a handful of examples for Spring Social. Most notably, spring-social-showcase-boot is a new example that takes advantage of Spring Boot's simplified programming model to enable Spring Social to work with Facebook, Twitter, and LinkedIn.

Upvotes: 1

Related Questions