Wednesday, September 17, 2008

Netflix API - Getting OAuth to work on iPhone - part 2: Adding the OAuth Code

To start with I found some examples by Nick Dalton that helped me build a simple application that included a Web View, a screen that acts like a web browser but with my custom Objective-C code embedded in it. This is important, because the OAuth sign-in process uses a web page, but on the iPhone, if you spawn a copy of Safari to visit a web page, your application quits first.

Next the Source Code Manager in Xcode was configured to load the OAuthconsumer Objective-C framework via subversion. This was easy and obvious, enter the URL http://oauth.googlecode.com/svn/code/obj-c/ and checkout the code.

When trying to import the framework I discovered that Apple does not allow user specified binary frameworks to be added to iPhone applications. To work around this the source code was copied from the Xcode project for the framework, to the Xcode project for my Instant Test application. I renamed the  framework Classes folder as OAuth and copied to my project via drag and drop, choosing to copy the underlying files. The Cocoa Categories, Protocols and Other Sources>Crypto folder were also copied. The Tests folder did not compile for iPhone so don't bother to copy it over.

The standard system Security.Framework doesn't need to be added to the Frameworks folder. I initially thought it did, but its probably only needed for the KeyChain code.

The iPhone doesn't support the KeyChain functionality, so if you try to build for iPhone it will fail. It does however build for the iPhone Simulator, which is confusing. Open up the OAuth source code, and delete the last two files OAToken_KeychainExtensions.h and OAToken_KeychainExtensions.m.

Since the code is no longer a framework, the header file references need to be changed from #include to #include "file" for all the includes in OAuthConsumer.h apart from the first Foundation one.

At this point, before you try and call anything, try a build, it should compile with no errors. If it doesn't, look for missing files.

At this point, you should have all you need to connect to an OAuth service

Tuesday, September 16, 2008

Netflix API Getting OAuth to work on iPhone - Instant Queue Add part 1: why?

Why develop an iPhone app? Its "the future", a useful skill, and I can carry whatever I develop in my pocket and make it do whatever I want.

I work at Netflix, and I have instant watching on my TV, I built an application "Instant Queue Add" that lets me add a title to my instant queue using my iPhone in a couple of touches. It takes the Top20 and New Choices RSS feeds to find content, and it spawns a copy of Safari to add to instant queue for each pick. The first time it starts, you have to login, then it remembers the Netflix cookie. However I really want to add more features and avoid spawning a copy of Safari with a screen scraped URL.

The Netflix API uses a new standard called OAuth for Open Authentication. There are lots of features, but its complex, and there is no standard off the shelf library for OAuth on the iPhone. However it is a useful building block for more advanced applications.

In this series of posts, I will document the steps I'm making to get OAuth to work on the iPhone using Objective-C and Xcode. My starting point is this code base and tutorial by Jon R. Crosby, which is based on desktop MacOS X, and doesn't directly support the iPhone.

Monday, September 8, 2008

Intel high speed SSD

Here is Tech Report's review of Intel's high speed SSD, which confirms the trend I've been talking about for a while. SSD's were always faster for random read and write, now they are faster for sequential read (250MB/s), and the "extreme" Intel model is faster for sequential write as well (170MB/s). They use less power and have comparable MTBF to the best enterprise disk drives.

The remaining disadvantages of total size and cost are being eaten away over time...