From the course: Calling REST APIs with Java

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Solution: Twitter API

Solution: Twitter API - Java Tutorial

From the course: Calling REST APIs with Java

Start my 1-month free trial

Solution: Twitter API

(upbeat music) - [Instructor] Okay, I'll show you my solution to the challenge but keep in mind, you can solve this in many different ways. I started my work inside of the stream method within the Twitter streaming service class here I instantiated a client using the builder that was injected into the class by spring. The first thing I needed to do to create the client was specified the base URL, which is the Twitter API domain. I then added a default header to satisfy the OAuth two security scheme on the Twitter API. By specifying a default header that provided our bearer token on the client. It causes the bearer token to be sent with every request. Once I had this security in place I then called the build method to instantiate the client. Next, it was on to making the call that would connect our client to the stream that's provided by the Twitter streaming API. To make that connection. I needed to use the fluent API of…

Contents