Nov 07

The first task I gave myself with Celery is complete. I can now search for a food, obtain a list of foods that match my search criteria, select one and get more information. This little task allowed me to learn a significant amount including:

  • Using oauth and a Cocoa library to communicate
  • How to build and add third party frameworks to Xcode
  • How to parse JSON using a Cocoa library
  • Creation and usage of Protocols
  • Usage of the NSTableView class.

The first two points have been mentioned previously. I will go into more detail about the last three in future posts.

Here is a screenshot of the application.

CeleryScreenSnapz001

As you can see it is quite ugly and utilitarian. This of course is not how I plan to make the app, but just needed something to learn from. One of the beauties of using MVC, which Cocoa is really built around, I can yank the View (V) and replace it with almost no code change. Just hook up the outlets to the new UI in Interface Builder and it will continue to work as before… beautiful.

Tagged with:
Nov 01

The first task I gave myself when writing the Celery Application is to obtain nutritional information for various foods. I’ll need to provide a means to request a list of food that matches a search query and a way of getting more information about a particular food from that list. As I mentioned before, I found the FatSecret REST API, and decided to use this for these two requests. FatSecret supports “foods.search” and “food.get” methods that meet my needs. FatSecret also uses oauth for authentication.

My list of tasks were as follows:

  1. Obtain the necessary keys to communicate with FatSecret.
  2. Find a Cocoa Library to use oauth.
  3. Establish a connection and call methods as needed.

1. Obtain the necessary keys to communicate with FatSecret. This was easy enough, simply went to this site and registered the application I was making. This provided me with a Public Consumer Key and the applications Private Key. These keys were emailed to me, and they were ready to be used.

2. Find a Cocoa Library to use oauth. As I mentioned in a previous post, I found MPOauthConnection for establishing an oauth connection and calling methods on a REST Library. I downloaded the source using Subversion and opened the library. After running the Build, Xcode proceeded to lock up completely. All I got was the Beachball of Death. I stared at it, tried a couple more times, but could not successfully build the project. After awhile, I noticed that it was failing to proceed past the Unit Tests. I figured, I’m not modifying the Library, and therefore, don’t really need to run the Unit Tests. So, I opened up the Unit Test target and deleted it. Kicked off the Build and it succeeded.

I was going to start up the Celery project, but decided to go ahead and modify the existing test application to communicate with FatSecret.

3. Establish a connection and call methods as needed. The first thing that I had to do was match up what MPOAuthConnection expects to what FatSecret API expects, including slightly different nomenclature. I started by plugging in the values for the Base Host URL, Shared Secret and Consumer Key and the method to call. The method to call stumped me a bit, as the FatSecret sets the actual method to a parameter (method=VALUE). Where the method for the API is server.api. That really took me awhile to figure out. Secondly, the provided example had no usage of method parameters (making it a very flawed example, in my opinion). I struggled then to figure out the API to pass parameters, finding a Unit Test in code, I was able to figure this out and successfully make calls to the API, searching for a food, and getting information for that food.

The next step will be to build my own Celery project and duplicate this functionality in what will become my own Application.


Tagged with:
Oct 25

After some research I’ve settled on the FatSecret Platform API for the WebService I’m going to use. FatSecret is a webapp that does much of what I want to do on the desktop. In fact, it seems solid enough that a partnership in the future could be beneficial. However, until that magical day, I’m simply going to make use of their Food Database.

There are a couple bits of technology that I’ll be with here, REST (Cocoa libraries for it) and oauth. All REST requests are signed via oauth and provide the ability to store data on their server (they provide capabilities for tracking your food, exercise, etc). I won’t be making use of that functionality (possibly in the future), but even to gain access to the Food DB, I need to use oauth.

oauth was started by Blaine Cook and Chris Messina as a way to provide a mechanism to obtain secure data without having to provide information about their identity. Its intention is to allow access to multiple Web Services without logging into them all, but using a single oauth credential. Think Web Service Mashups.

So, I had two requirements to obtain some food data. I need to communicate with a Web Service via REST and authorize requests via oauth. After searching for my options, I came across MPOAuthConnection for Cocoa. I downloaded the project from Google Code and set off down the path.

Tagged with:
preload preload preload