Retrieving Tweets

Add the following to the index.html (Replace “chyneyee” with your Twitter username):

<script src="https://api.twitter.com/1/statuses/user_timeline/chyneyee.json?callback=updateTweets"></script>

Add the following code to the js file:

// tweets passed a response containing the tweets from the user timeline as an array of tweets.
function updateTweets(tweets) {
 var tweetsSelection=document.getElementById("tweets"); // grab a reference to the tweets selection from the form.
 for (var i=0;i<tweets.length;i++) {
 tweet = tweets[i]; // get a tweet from the array
 var option=document.createElement("option"); // Create a new option element
 option.text=tweet.text; // Set its text to the tweet
 option.value=tweet.text.replace("\"","'"); // replace double quotes with single quotes


Twitter Output

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

chin yee

Leave a Reply

Your email address will not be published. Required fields are marked *

Current ye@r *

What is 5 + 9 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)