Book Image

SPRING COOKBOOK

By : Jerome Jaglale, Yilmaz
Book Image

SPRING COOKBOOK

By: Jerome Jaglale, Yilmaz

Overview of this book

This book is for you if you have some experience with Java and web development (not necessarily in Java) and want to become proficient quickly with Spring.
Table of Contents (14 chapters)
13
Index

Posting a Facebook status update

In this recipe, you'll learn how to post a status update on a Facebook user's Timeline from a Spring web application.

Getting ready

This recipe uses the code from the Connecting to Facebook recipe.

How to do it…

Here are the steps to post a status update on a Facebook Timeline:

  1. In the FacebookController class, in the login() method, add publish_actions to the scope parameter:
      params.setScope("public_profile, publish_actions");
  2. In the fb() method, in the if(facebook.isAuthorized()) block, use the Facebook object to post the status update:
    facebook.feedOperations().updateStatus("This was posted from a Spring web application.");