Latest Register Log In

+ Advanced Search

Twitter Feeds

Twitter Feeds
05/18/14 (Edited 05/20/14)

Note: Requires WSN 9.0.9 or later.

Integrating the content of a twitter feed can give your site fresh content without effort. You can make a feed of your own tweets, or of another twitter user, or of everyone using keywords related to your topic.

Twitter requires that you authenticate with a bunch of special tokens, so you'll need to set these up first. Create a new app at and then generate an access token for it. Copy the api key, api secret, access token and access token secret into the twitterapikey, twitterapisecret, twitteraccesstoken and twitteraccesstokensecret tweaks at Admin Panel -> Settings -> Tweaks Editor in WSN. If you don't enter these details, you'll be using the default wsnphp access info which may quickly hit the requests limit and cause you problems.

Next, go to Admin Panel -> Settings -> Social and create your feed at the bottom. If you want to show tweets by a particular user, type @username. For a hashtag, type #hashtag. For a plain search just type the search term. After submitting, you'll be presented with the template code you'll need to copy to where you want the tweets displayed.

The following template variables are available for tweets:

{TWEETPROFILEIMAGEURL} - The user's profile image.
{TWEETNAME} - The username.
{TWEETSOURCE} - The source of the tweet, such as web or mobile.
{TWEETTEXT} - The actual text of the tweet.
{TWEETTIME} - The time and date it was tweeted.
{TWEETIMAGEURLBOOL} - True if there's an image in the tweet, false if not.
{TWEETIMAGE} - The URL of an image included in the tweet, in case you want to display images (this can mess up your layout so be careful).

For educational purposes, here's an example using everything:

<div class="socialfeed">
<h3>@wsnphp on twitter</h3>
<!-- BEGIN TWITTER FEED @wsnphp|5 -->
<div class="tweet">
<div class="tweetheader"><img src="{TWEETPROFILEIMAGEURL}" class="tweetprofileimage"><b>{TWEETNAME}</b> via {TWEETSOURCE}</div>
<div class="tweettext">{TWEETTEXT}</div>
<div class="tweettime">{TWEETTIME}</div>
<IF {TWEETIMAGEURLBOOL}><div class="tweetimage"><img src="{TWEETIMAGE}"></div></IF>
<div class="clear"></div>
<!-- END TWITTER FEED @wsnphp|5 -->

Please note that twitter feeds will be cached for one hour in order to speed the display and lower the chances of hitting the API use limits. To bypass the cache, you can add a nocaching=1 parameter to the URL of the page.

Description How to integrate a twitter feed into your templates.
Views 191 views. Averaging 0 views per day.