In my last post I discussed about how to display tweets on your webpage in the most easiest way. This post will continue the Twitter series and deal with the situation when you want to load tweets of a specific user on the fly or at run time. The focus of this post is to help you when you are planning to implement any one of the following or all things-
- Coding a webpage and want to display the tweets without and IFrame.
Update: Twitter has deprecated v1.0 API since today (12th June 2013) and the below code will not show any tweets to you.
To get started, lets build the HTML markup first. Place the below tag in your
In the above code, in line 4 you notice the statement ‘loadLatestTweet(10, “niteshluharuka”);’.
This function requires 2 parameters –
- 1st parameter is the number of tweets you want to load. If you want to load 5 tweets, pass the value as 5 instead of 10 as passed by me.
- 2nd parameter is the account name you want to load the tweets from. So, if your twitter handle is “mytwitterhandle”, then pass ‘mytwitterhandle’ in the function and the function will look like below-
Once you are able to get the tweets on your page, its time to give some style to your tweets. Copy and paste the below CSS in your head section
Below is the complete code –
Hope you enjoyed reading this post and find this helpful. Comment your experiences and let me know in case you face any issues while implementation.