Archive for the ‘Side Projects’ Category

Solution Setup

For this project, I went with my tried and true solution structure:

/root
   /lib
   /src
   /tools

I copied the System.Web.Mvc assembly to the lib folder and updated the reference accordingly.  I always recommend this approach especially when dealing with pre-release libraries.  The New Project dialog adds a reference to the default installation directory for the ASP.NET MVC version you choose.  This is usually “C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies”.  The problem with this is that your web host probably doesn’t install pre-release software.  By including it as a local library and setting “Copy Local” to true you can ensure that the required version is copied to the output directory.  It also helps when you add to version control and want to update the library to the latest release candidate.
copy local true

I also did the same for the LinqToTwitter and DotNetOpenAuth libraries.

Razor Template

Before you start using Razor templates, I highly recommend you read Scott Guthrie’s overview on Razor layouts.   There’s a couple new files you need to be familiar with including  _ViewStart.cshtml and _Layout.cshtml.  Essentially, _ViewStart removes the need for you to explicitly set the layout for each view you add and specify any common view code you want to have execute before rendering the view.  _Layout is what you commonly know as your Site.Master page.

First Try – Twitter API

To wrap this post up, I want to just take a quick look at wiring up all the Twitter API authentication process. The first step to get OAuth working is to get a consumer key and secret from Twitter. It’s a quick and easy process. Just go to https://twitter.com/oauth_clients and select “Register a New Application”. Complete all the required fields and you’ll be presented with the key and secret. Make sure you select “Browser” as the Application Type. Don’t worry about the callback URL for now – just put http://google.com or something similar for now.

Next, add the required assemblies that you downloaded with Linq to Twitter to your project. These include LinqToTwitter.dll and DotNetOpenAuth.dll. An important step is to create a class that implements the IConsumerTokenManager interface in the DotNetOpenAuth library. This is the class that will manage all the access tokens and secrets for OAuth. For the sake of this quick POC, I’m using the InMemoryTokenManager included in the Using OAuth with ASP.NET MVC sample project. The only configuration change you have to make is to add a your consumer secret and key to the Web.config as illustrated below:

Linq to Twitter Configuration Settings

Linq to Twitter Configuration Settings

Take a look at that project to get a quick connection to the Twitter API going. I ran my project and was able to connect exactly as expected. Next time we’ll look at the wireframes for the application and getting more of the functionality of the site going.

Overview

Have you ever tweeted something that you would like your friends to retweet as soon as possible.  I’ve seen this with new product announcements, Twitter contests, building buzz and even when applying for a social media gig.  Usually the tweet includes something like “Pls RT!”  With this project, I thought I’d create a retweeting engine to announce to your friends that you have a status you’d like them to retweet.  This sounded like a great opportunity to deep dive into the Twitter API and OAuth within .NET application.  Hence a neat side project that may have some usefulness and will definitely get us exploring some important API’s.

Technology Stack

Twitter API

There are plenty of good .NET Twitter Libraries available with varying degrees of functionality.  I am a huge fan of Linq so I decided to give Linq to Twitter a spin since it has high API coverage and supports oAuth out of the box.

ASP.NET MVC R3

I’ve been using the ASP.NET MVC framework since it’s first community preview several years ago and have fallen in love. It has evolved in many ways since the first CTP and I’m looking forward to experiment with some of its newest features – particularly the Razor view engine.

OAuth

I believe the best way to get up to speed with an API is to jump right in and start working with it.  One of the components I’m most excited to explore is the OAuth implementation for the Twitter API.  With more and more services adopting the OAuth protocol, I think its safe to expect it to become the de-facto security layer for most social API’s available.

Other Tools

As to the other frameworks and tools involved in the project, you can expect to see the usual suspects. At this time I don’t think they’ll be a need for a database since most of the data will be coming from the Twitter API. The tools of the trade up to this point will include:

  • Visual Studio 2010 Ultimate
  • jQuery v1.4.4

I’m looking forward to sharing the experience step-by-step so don’t be surprised if I hit some speed bumps (or canyons) along the way. In the next part we’ll look at some preliminary solution setup and wiring some of the external libraries together. We’ll also mockup some screens and see what views and controllers it would be implying.

UPDATE:  Installation of .NET 3.5 SP 1 on my web hosting completely killed this app!  I’m currently going through the process of upgrading it but it will be down for a while.

I am officially announcing the beta release of the GiftListr for Facebook application.

GiftListr is the only truly universal gift registry allowing you to add products from ANY website without limitations.  Just browse stores the way you usually do when you shop online.  Once you find the item you want, simply copy-and-paste the url into the GiftListr application.  GiftListr will then download all the product information and product images available.  You can add notes to each item and share you gift list with friends.

The application is built entirely on ASP.NET MVC and makes extensive use of the jQuery library.  It also uses the Facebook Developer Toolkit available on CodePlex.  I would love to hear some feedback from the ASP.NET community.  Let me know what you think.  Any features you’d like to see?  Would you be willing to contribute to it if I add it to CodePlex as a community project?