Book Image

SPRING COOKBOOK

Book Image

SPRING COOKBOOK

Overview of this book

Table of Contents (19 chapters)
Spring Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Sending a private message to another Twitter user


In this recipe, you'll learn how to send a private message to another Twitter user from a Spring web application. Note that the user who is the recipient has to be a follower of the user who is the sender.

Getting Ready

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

How to do it…

In the TwitterController class, in the tw() method, use the Twitter object to send a private message to another Twitter user:

twitter.directMessageOperations().sendDirectMessage("jeromejaglale", "Hey Jerome, I'm just testing your recipe.");