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

Introduction to Twitter's API Forum

View Course » View Exercise

166 points
53008aff204e5a9f346503c38375d5d1?s=140&d=retro
Submitted by
LupeBrown91
over 4 years ago

Can read the tweet but still getting an error?

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

baseurl = "https://api.twitter.com"
path = "/1.1/statuses/show.json"
query = URI.encodewwwform("id" => "266270116780576768")
address = URI("#{baseurl}#{path}?#{query}")
request = Net::HTTP::Get.new address.request_uri

def printtweet(tweet)
puts JSON.pretty
generate(tweet)
puts tweet["user"]["name"] + ' - ' + tweet["text"]
end

Error reads: "You did not generate the correct output. Did you print the username, followed by ' - ', followed by the Tweet text? "

The tweet says:
"Raffi Krikorian-want to work on large scale? "Of course, we still have plenty more to do." #JoinTheFlock
http://t.co/cEoSgiip
nil "

All help appreciated. Thanks.


0 votes

permalink

Lupe,
get rid of your 12th line of code:
puts JSON.prettygenerate(tweet)

Get rid of it... I don't really understand why, but this fixes the problem.
you can just comment it out... #...
then it will work

834 points
7330c524591ef2488dc5b537394c0871?s=140&d=retro
Submitted by
Roane
over 4 years ago