This forum is now read-only. Please use our new forums at

154 points
Submitted by
Chris Swart
about 4 years ago

Code fulfills conditions for Reading a Tweet 5/3 Twitter API but doesn't pass

Hi, my code fulfils the required conditions but doesn't pass the test so I rewrote it and just copy pasta-d some answers I found here and it still doesn't work. My answer is in the correct format and I see no issues with it. Cheers for the help.

require 'rubygems'
require 'oauth'
require 'json'

# Now you will fetch /1.1/statuses/show.json, which
# takes an 'id' parameter and returns the
# representation of a single Tweet.
baseurl = ""
path    = "/1.1/statuses/show.json"
query   = URI.encode_www_form("id" => "266270116780576768")
address = URI("#{baseurl}#{path}?#{query}")
request = address.request_uri

# Print data about a Tweet
def print_tweet(tweet)
  puts tweet["user"]["name"] + " - " + tweet["text"]

# Set up HTTP.
http             =, address.port
http.use_ssl     = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER

# If you entered your credentials in the first
# exercise, no need to enter them again here. The
# ||= operator will only assign these values if
# they are not already set.
consumer_key ||= "ENTER IN EXERCISE 1", ""
access_token ||= "ENTER IN EXERCISE 1", ""

# Issue the request.
request.oauth! http, consumer_key, access_token
response = http.request request

# Parse and print the Tweet if the response code was 200
tweet = nil
if response.code == '200' then
  tweet = JSON.parse(response.body)

14 votes


The user name has changed. Just use: puts "Raffi Krikorian" + " - " + tweet["text"]

667 points
Submitted by
Riley Lloyd
about 4 years ago


52a718d8631fe90b650025c1_946298301 Chris Swart about 4 years ago

Cheers for the help :D

Picture Liz Pullen about 4 years ago

This was so frustrating. Thanks for providing an answer. I wish the instructions would be updated.

52a93164548c35041300071f_347599267 纸盒 Danbo over 3 years ago

Can't believe this ....