Call today on freephone 0808 14 333 00

Affordable Business Websites

RAR Top 100 Recommended Agency
Leveraging the power of the internet with affordable, award winning web sites and business marketing tools for small to medium-sized business

Integrating Your Twitter Feed into your site using Classic ASP

March 27th, 2009 - , , , ,

We like Twitter, here at Sizzle. We don't really 'get' it, but we like it nonetheless. However, we were recently struck upon a conundrum - how to integrate our most recent 'tweets' into our site using ASP. We could find code snippets for PHP and ASP.Net, but not ASP itself. Fortunately, we eventually happened upon a ridiculously simple solution: Use your Twitter's RSS feed!

Using the code from here and substituting our RSS feed for the provided example, we were able to easily pull down our 20 most recent tweets. A bit of code-chopping, and we trimmed it down to a svelte layout. We were nearly done, but not quite... Our links were being served as plain, unclickable text! So we implemented this nifty yet very basic bit of business to separate out link-laden tweets and add the appropriate <a> tag:

if inStr(sTitle,"http://") > 0 then
linkposition = inStr(sTitle,"http://")
linkposition = linkposition - 1
stringlength = Len(sTitle)
texty = Left(sTitle,linkposition)
texty = Trim(texty)
linkposition = stringlength - linkposition
link = Right(sTitle,linkposition)
response.Write "<div class='tweet'>"&texty&"<br />"
response.Write "<a href='"&link&"'>"&link&"</a></div>"
else
response.write "<div class='tweet'>"&sTitle&"</div>"
end if

..And voila! Our tweets, served up in lovely div classes, ready for insertion into our Javascript-powered homepage box. Note: By default, the linked script caches RSS feeds for 1 hour, which'll stop your server from harassing Twitter's too much. It's easily amendable, but we're not sure if we'd recommend it.

1 Comment »

Thank you for this code. I was able to include my twitter feed into my website correctly.

Regards.

Comment by Phillipe Calmet

TrackBack URL

Leave a comment