Since the retirement of version 1.0 of Twitter’s API is underway, I’ve been updating the Twitter integration code in the Techozoic Fluid theme. I don’t agree with all the changes to the API, especially the requirement that all API requests, even for public info, must be signed. Luckily someone has already done the hard work creating a library for signing the requests with the proper oAuth signatures. The tmhOAuth library can be found on Github. It will be required for the new functions.
The first step is to register a new Twitter application. After signing into Twitter visit the Applications area of Twitter, and create a new application. After creating the application make sure create the access token at the bottom of the Application screen, this will authorize the application to access your account. You will now need 4 separate keys to properly sign the API requests. You’ll need the Consumer key, Consumer secret, Access token, and Access token secret. These will be added to an array and passed to the function and in turn passed to the oAuth library to sign the request.
These two functions below can be used to pull your Twitter timeline and automatically convert all links, hashtags, usernames, and media to the proper format using entities. The same function can also be used to pull a follower count. Examples of how to use are included in the code below.

By Simple WordPress Twitter follower count snippet | Jeremy Clark - TechNet.com March 7, 2013 - 2:43 pm
[…] Updated version for API v1.1 Following on the idea from this post, sometimes a full-blown Twitter plugin is too much. Luckily Twitter has a rich API that is ripe for the taking of information. The API console is of great use to find how to properly format the API requests. This code below will output the number of followers specified by the username passed to the function wrapped in a link to the page that allows the visitor to easily follow the user. […]
By TweetPressFr June 2, 2013 - 10:52 am
Hi, it’s funny I made a quite similar function for my website about 1/2 days ago. I wish I had found this good snippet, that would have saved me a lot of time to make my stats work.
I do not know if you know but your do not have to parse anything with tmhOAuth. You can do something like this : $entified_tweet = tmhUtilities::entify_with_options($tweet); to grab entities. To display other datas I use a foreach and I can grab id_str for exampel with just $tweet[‘id_str’]
By Jeremy Clark June 2, 2013 - 11:44 am
Good to know that. I had just reused an existing function I had written for API v1 requests. I didn’t really dig into the tmhOAuth too much more than just the basics for authentication.
By Julien Maury June 2, 2013 - 5:34 pm
Your code is great, I mean it works fine. But I’ve been trying to insert it in a shortcode function and I get only one tweet :/
By TweetPressFr June 3, 2013 - 10:21 am
I’ve been tested your code and it’s quite functional ! Error was due to me. Can I use it in a plugin? Of course I will quote you as source. Just want to offer my user possibility to get more than 1 tweet.
By Julien Maury June 3, 2013 - 1:03 pm
Just want to let you know I’m gonna update my plugin with your code. I’ve added this URL as source. Just tell me if that’s ok for you and do not hesitate to review the plugin : http://wordpress.org/plugins/jm-last-twit-shortcode/
By Jeremy Clark June 3, 2013 - 2:09 pm
I’m fine with you using in your plugin, and thanks for the link back. I’ll have a look over the plugin. Glad you found it that helpful to use in your plugin.
By Julien Maury June 3, 2013 - 2:47 pm
Thanks, I do not really know why it used to fail with former code maybe because I was not using a PHP while(). What continues me to perplex is whyyour method seems to have better results (with entities) than with tmhOAuth entitfy, any hint?