Monday, July 12, 2010

FatSecret Sharp - C# Nutrition and Exercise Tracking Services


I started looking into FatSecret.com's REST API this weekend after wondering how hard it would be to make a Food Tracking App for Win Phone 7.


My first step was to take a look at their REST API Documentation, which shows a list of their available methods and how to authenticate using OAuth. It turns out, the hardest part of being able to get data from their services is the OAuth stuff.


OAuth Primer



Basically, OAuth works like this; You get a Consumer Key and a Consumer Secret from their API. You use these to "Sign" your requests. The "Signature" is built up using 3 components joined by an "&"; The method you are using to request (POST or GET), the uri of the service (Url Encoded), and the query parameters (ordered alphabetically by key, then value, then Url Encoded).



{HTTPMethod}&{ServiceUrl}&{OrderedParameters}

GET&http://platform.fatsecret.com/rest/server.api&a=foo&oauth_consumer_key=demo&oauth_nonce=abc&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345678&oauth_version=1.0&z=bar


Final Version:

GET&http%3A%2F%2Fplatform.fatsecret.com%2Frest%2Fserver.api&a%3Dbar%26%26oauth_consumer_key%3Ddemo%26oauth_nonce%3Dabc%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D12345678%26oauth_version%3D1.0%26z%3Dbar


Then you make your request and hope everything matches up on their side.


FatSecret C# Service Wrappers



The end result of digging into the API was a library to wrap the nutrition and exercise services. Now there is an easy way to search for nutrition information in C#. Visit the FatSecretSharp project on codeplex for examples and code. I'm hoping to start making a Win Phone 7 Application for Food Tracking in the next couple weeks.



Now Playing: Weird Al - Fat

Wednesday, June 23, 2010

My Sail City - Win Phone 7


I've been working on a website in my spare time that tracks sailing trips and lets you share them with your friends. The site uses the new HTML5 GeoLocation API's for tracking a user's movements on the water and then giving a grade to the trip once they are done. Trip scores are based on time, distance and the weather conditions during their trip. Eventually, you get enough points to grow through the ranks.




I've also been looking into the new Win Phone 7 resources and wanted to make a proof of concept out of the website. Here is the result, a quick demo of a Win Phone 7 app that uses MVC 2 as it's service layer. I created a new "Area" (a new feature in .Net MVC 2) called API that exposed most of my necessary data as JSON based REST-like services. I'll try to post something with more technical detail later.























Now Playing: Styx - Sail Away (come on, that's like... mandatory song attribution...)

Friday, April 23, 2010

Exceptional Visualizer

This is a shameless cross post of the project introduction for a new project I just started on CodePlex to help with debugging complex PRISM dependency resolution errors called Exceptional Visualizer.




Project Description


A Debugger Visualizer for Visual Studio 2008 that allows for effective visual tracing of deep Exception stacks. Useful for Unity Resolution Exceptions as seen in PRISM (Composite Application Guidance); such as Microsoft.Practices.Unity.ResolutionFailedException and Microsoft.Practices.ObjectBuilder2.BuildFailedException.

Screen Shots


Screen 1

Screen 2

Screen 3

Other Info


This project displays the Exception information in a WPF window. This is an example of a Debugging Visualizer that uses WPF for visualization.

Now Playing: Otis Taylor - Nasty Letter