Ajax-loader-large-white
Introduction to Twitter's API
Reading a Timeline

This exercise introduces the /1.1/statuses/user_timeline.json endpoint, which returns a list of the public Tweets from an account in reverse chronological order.

We introduce the idea of modifying a request response through some common parameters, in this case count which controls the number of results returned by endpoints which return multiple Tweets.

Instructions

Add an implementation of print_timeline which iterates over every returned Tweet and prints its text attribute.

Change the count parameter in the request to 10 to print the last ten Tweets from the @twitterapi account.

?
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

The user_timeline.json output is just an array of Tweets, so you can call

tweets.each do |tweet| ... end

to loop over its contents.

script.rb