Show a twitter feed

So this is an easy favorite that I like. A simple default twitter feed on the web. Many configurations are configurable, so take a look here and play around with it.

1. Just put it in your code where you want it to lie.

                            <div style="text-align:center;">
                                Latest tweets <a href="#fillinyourtwitterurlhere" target="_blank">@yourtwitterhandle</a>
                            </div>
                            <div>
                                <script charset="utf-8" src="https://widgets.twimg.com/j/2/widget.js" type="text/javascript" language="javascript"></script>
                                <script type="text/javascript" language="javascript">
                                    new TWTR.Widget({
                                        version: 2,
                                        type: 'profile',
                                        rpp: 2,
                                        interval: 30000,
                                        width: 250,
                                        height: 100,
                                        theme: {
                                            shell: {
                                                background: '#ebebff',
                                                color: '#7b77bd'
                                            },
                                            tweets: {
                                                background: '#ebebff',
                                                color: '#7b77bd',
                                                links: '#c70000'
                                            }
                                        },
                                        features: {
                                            scrollbar: true,
                                            loop: false,
                                            live: true,
                                            behavior: 'all'
                                        }
                                    }).render().setUser('yourtwitterhandle').start();
                                </script>
                            </div>

Advertisements

Twitterize your web app

I love this binary that makes it easy to do Twitter integration. http://www.twitterizer.net/

I’ll give a VB example here of how you might be able to use it.

1. Down the DLL or files or whatever works best for you and add a reference to in your project

2. Add the import

Imports Twitterizer

3. Go to Twitter developer and get your OAuth credentials. If you don’t know how to do that, it’s easy, it’ll walk you through setting up a new App. Just a couple of points here.

  • On the Application Type, make sure you select at least Read and Write if you want this example to work. If you select only Read and later want to change it, that’s fine, but you’ll probably need to regenerate new OAuth keys as the old ones probably won’t let you Write. I think I learned this the frustratingly hard way.
  • Now, the OAuth tool with the various access token consumer and secret keys are really what you’re after. I can’t recall if you need to setup an @Anywhere domain or not, but read up on that to be sure.

4. Once you’ve got your OAuth credentials, you’ll want to keep them secret to yourself, but you can use them in your code now

        Dim tokens As New OAuthTokens()
        tokens.AccessToken = "xxxx"
        tokens.AccessTokenSecret = "xxxx"
        tokens.ConsumerKey = "xxxx"
        tokens.ConsumerSecret = "xxxx"

5. Now, post an alert to Twitter! That’s it. You’ll notice the Twitterizer API also has a synchronous post if I recall, but not real sure what application would desire that blocking behavior.

                Dim asyncResult As IAsyncResult = TwitterStatusAsync.Update(
                    tokens,
                    "hello Twitter from App",
                    Nothing,
                    New TimeSpan(0, 1, 0),
                    AddressOf WhenUpdateIsCompleted)