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

118 points
Picture
Submitted by
Nick Riley
about 4 years ago

It says First, change the id parameter of the request to load the Tweet with ID 266270116780576768. Second, print that Tweet on a single line in the following format "USERNAME - TWEET_TEXT".

First, change the id parameter of the request to load the Tweet with ID 266270116780576768.

Second, print that Tweet on a single line in the following format "USERNAME - TWEET_TEXT".
I am having trouble finding where this goes , can some one help me ?


3 votes

permalink

You need to add the tweet ID in line 10, where it says "TWEET ID GOES HERE".
Replace "TWEET ID GOES HERE" with "266270116780576768" but keep the " ". The "266270116780576768" should still look green.

The second part needs to go in line 17 (add a new line). In line 16 it says " # ADD CODE TO PRINT THE TWEET IN " - " FORMAT".
So add a new line 17 and write:
puts tweet["user"]["name"] + " - " + tweet["text"]

So in the end that part should look like this:
line 15: def print_tweet(tweet)
line 16: # ADD CODE TO PRINT THE TWEET IN " - " FORMAT
line 17: puts tweet["user"]["name"] + " - " + tweet["text"]
line 18: end

612 points
30a3b2c53aa41697bbb6c08675472cf4?s=140&d=retro
Submitted by
OlafBom
about 4 years ago

1 Comment

Picture Luke Phillips over 3 years ago

Works! But you don't actually need the quotations around the tweet ID because its a number


2 votes

permalink

First and foremost...

  • These API lessons are teaching concepts that are constantly evolving. Each of these API courses involve a 3rd party API that can change on a moments notice (can you say FB?)
  • The requirements are outlined in the source code mixed with instructions, but digging through it is a pain. I consider myself an intermediate/experienced developer, and I knew what to do, and I still got a tad lost.
  • The course instructions are definitely more geared towards intermediate programmers who know what they're looking for.

I want to help people pass this lesson, because this was written (as well as the other API docs) as a template that isn't relevant or expanding enough information to utilize them externally.

Second:

Change this line...

query   = URI.encode_www_form("id" => "TWEET ID GOES HERE")

to show this:

query   = URI.encode_www_form("id" => "266270116780576768")

Change your print_tweet function:

# ADD CODE TO PRINT THE TWEET IN "<screen name> - <text>" FORMAT

to show this:

puts tweet["user"]["name"] + " - " + tweet["text"]

I would recommend reading up here: if you want to expand your knowledge.
http://programmers.stackexchange.com/questions/90531/how-to-learn-an-api

2126 points
512d3f8f7df8cbb462001736_165830919
Submitted by
Nicholas Hazel
over 3 years ago


0 votes

permalink

DOESNT WORK

79 points
20750dd5caaf7bb17772b32d711a3e4e?s=140&d=retro
Submitted by
lemonsxorange
about 4 years ago


0 votes

permalink

works

28 points
Picture
Submitted by
Salahuddin Al-Ghazālī
almost 4 years ago


0 votes

permalink

I finally figured out what the problem was. ' _ ' not " _ "
to make it easier I've included the solution below.

Replace everything from line 14 to line 18 with this:

#Print data about a Tweet
def print_tweet(tweet)
puts tweet["user"]["name"] + ' - ' + tweet["text"]
# ADD CODE TO PRINT THE TWEET IN " - " FORMAT
end

467 points
51c3398e8c1cccc26d000019_993029465
Submitted by
Kevin
over 3 years ago