Twitter Feedstream Your Twitter Feed To Your Site!

broken image


  1. Twitter Feedstream Your Twitter Feed To Your Site Website

A twitter feed is a great way to breath a little life into an otherwise static website. Check out the bottom right corner of my portfolio site as an example.

Update: Twitter upgraded their API to version 1.1. The code in this post no longer works, but you can reference the Twitter feed module that I wrote for SuperFeed to see how to use the new API. Also, I no longer have a twitter feed on my portfolio site.

The Tweet button allows you to quickly share the webpage you're viewing with all of your followers. Clicking the Tweet button provides you with a pre-populated Tweet containing a link to that webpage, which you can customize before sending. How to put the Tweet button on your site. Official Twitter Feed Widget The most direct approach is to put the official Twitter widget on your website. The widget can be embedded on any website that allows the use of JavaScript (which is most websites). The widget is also smart enough to handle some size adjustment if you are using a responsive website.

The Code

Twitter Feedstream Your Twitter Feed To Your Site!

So let's get right to it. With C#, a little LINQ, and the excellent twitter API, something like this is relatively easy to do. Here's the code (more or less) that I use on my website:

The Walkthrough

First things first, you'll want to change the screen name on line 8, and maybe the values on line 9 and 10 to your liking.

Line 19 sets up a while loop with a defensive try/catch block inside to retry the API request, just because the internet isn't perfect and you never know when a request will fail. If the max number of attempts is reached without success, the final output will be null, so make sure your code can handle that.

Lines 23-25 are where the magic is. Feel free to test that URL directly in your browser. For more options, refer to the documentation.

Lines 41-45 use LINQ to pull out the actual strings that we want and package them into a tidy list. Oddly enough, every one of these strings is prepended with 'lonekorean: ' (or your screen name, obviously), so line 44 takes that out for us.

And that's it. The one thing I got stuck on while coding this was the namespacing for Atom. Notice how I apply it on lines 42 and 43 with 'xmlns +'. Just don't forget that part and you're golden.

Support >Promoting Your Website >Social Media

How to embed a Twitter feed onto your Create website

If you want to show your Twitter feed on your Create website, you can do so using Twitter's widget.

To set this up, please follow the steps below:

Twitter Feedstream Your Twitter Feed To Your Site Website

  1. First go to: https://twitter.com/settings/widgets/
  2. Once there, you will be prompted to log in to your Twitter account.
  3. Click 'Create New' from the top of the page.
    Here you will be able to set up your feed and how you would like it to look.
    Choose and customise how you you would like the feed, the copy the code provided.
  4. Once you have set this up you will need to copy the code provided below the example feed. Be careful to highlight this fully.
  5. Now you will need to paste this code into a HTML fragment on your Create website.You can read how to add HTML fragments to your website here
  6. Then you can insert the HTML fragment where you would like to see the feed on your live website.
    Please note, that the feed requires your domain name to work. So the full feed will not show up on your design screen or preview, so you will need to publish your website to see the feed working.
  7. Publish your website to start sharing your tweets live on your website.




broken image