Integrating Your Twitter Feed into your site using Classic ASP
March 27th, 2009 - asp, coding, tweets, twitter, web design
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:
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 »
Leave a comment
chrome corporate web design creative credits creative partner ecommerce web design ecommerce website firefox google graphic design manchester manchester web design NESTA nesta creative partner nesta grant pay monthly websites rochdale search engine optimisation seo manchester Sizzle Sizzle Media web design web design bury web design manchester web design rochdale website design manchester
Thank you for this code. I was able to include my twitter feed into my website correctly.
Regards.
Comment by Phillipe Calmet