Applying Twitter's API "Best Practices" In A ColdFusion Application

Posted June 1, 2010 at 9:11 AM

Tags: ColdFusion

Twitter has become one of the most widely used APIs in the world. And as with anything that has become hugely successful, Twitter provides us developers with a wealth of educational material from which to learn. In this presentation, we will examine the Twitter API architecture and do our best to implement Twitter best practices in a sample ColdFusion application. This exploration will cover HTTP authentication, request validation, multi-format responses, and meaningful status code usage.

 
 
 
 
 
 
Appying Twitter's API Best Pracitces In A ColdFusion Application. 
 
 
 

This is probably the only time I'll do this presentation. After giving it, I just didn't feel that confident about the contents. I got some good feedback; but, I just never felt like I connected with it at a core level. However, feel free to take a look at the slides and download the code (including the sample Task List application).




Reader Comments

Jun 1, 2010 at 10:06 AM // reply »
30 Comments

I really enjoyed the presentation Ben. The best part for me though was the way you handled the error handling. Loved the way you surround the processing segment with a CFTRY and then throw your own error at varying points to handle the correct return code to the caller. Very clever and clean way of building the API. I'll certainly be looking to use a similar system in future.

Though that mic needed to be thrown out of the window. ;)


Jun 1, 2010 at 10:10 AM // reply »
55 Comments

I think you should keep this presentation . . . improve it. This is a topic I could stand to learn more about, especially since there are good APIs out there such as Flickr ready to be taken advantage of.


Jun 1, 2010 at 11:00 AM // reply »
4 Comments

Hey Ben,

This was indeed a great presentation my man, well done, really changed my perception on RESTful services, something which I've always shyed away from.

One thing that did cross my mind later that day when I was reflecting on this is that I've seen some funky behaviour with IIS7. I think that by default IIS7 will throw it's own custom error pages whenever you set the response code to anything other than 200.

So, in your case where you're returning XML or JSON formated error messages and adding a status code for 40x of 50x errors then IIS7 will throw it's own HTML content rather than your XML error messages.

I've not had time to look at this and see if that's exactly the case but my gut instinct, and experience of trying to throw friendly exception messages that still carry 50x status codes tells me that IIS7's default behaviour may cause some issues.

Any thoughts or ideas?

Robert


Jun 1, 2010 at 11:55 AM // reply »
6 Comments

Excellent write up. I've been doing a lot of work with writing API's recently. Both RESTful and SOAP. We should chat sometime about an API framework / best practices for ColdFusion developers.


Jun 1, 2010 at 6:24 PM // reply »
8,836 Comments

@James, @Robert,

Thanks guys :) I am not sure about IIS7. I've only ever rocked out on IIS6 (and lower). I would think you'd be OK though since it's already been handed off to the JRUN server (I like to pretend like I know thing-one about JRUN).

@Lola,

Ok, maybe I won't give up on it so fast.

@Wil,

Sounds like a good time my friend.


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Formatting: <strong>bold</strong> <em>italic<em>







  • Help Wanted - Find Your Next ColdFusion Job
Recent Blog Comments
Sep 9, 2010 at 12:50 AM
New ColdFusion Error: Form Entries Incomplete Or Invalid
Once again you save my day Ben. Just migrated from Railo to CF9 and that error was everywhere, I was on the verge of tears... ... read »
Sep 8, 2010 at 7:28 PM
What ColdFusion Teaches Us About The Ultimate "Roll Your Own" Solution
This is how good enterprise software and good enterprise architecture is built. In addition to the time factor and the abstraction potential, the most compelling reason I've ever found to incorporate ... read »
Sep 8, 2010 at 4:47 PM
Ask Ben: Reading In A File Using CFFile And CFInclude
@Ben, Thanks for the quick reply. That was the idea. The getFileFromPath returns a "52648.tmp" file name which is generated by the server not the actual file name. I'm not sure how to extract t ... read »
Sep 8, 2010 at 4:10 PM
Strange ColdFusion URLDecode() and GetEncoding() Behavior
Yep - too strange since the second arg in urldecode is optional. I did run across the error and googled it and landed safely here. Thanks, Ben! ... read »
Sep 8, 2010 at 3:33 PM
What ColdFusion Teaches Us About The Ultimate "Roll Your Own" Solution
@Steve, @Darren, Excellent point! Keeping a platform API (any API at that matter) allows for a much easier time to swap underlying libraries, or even to build your own. @Rick, @Jacob, @JC, I thin ... read »
JC
Sep 8, 2010 at 2:02 PM
What ColdFusion Teaches Us About The Ultimate "Roll Your Own" Solution
@Jacob -- absolutely. The trick is knowing when it'll take less time to do it yourself than wedge someone else's oval shaped application into your round hole. ... read »
Sep 8, 2010 at 1:49 PM
What ColdFusion Teaches Us About The Ultimate "Roll Your Own" Solution
@Rick, I hope this isn't too off topic but, is this true? I've only been programming in the workplace for 4 years. I often look at what others have done and adapt it to my particular needs. Often t ... read »
Sep 8, 2010 at 12:39 PM
ColdFusion CFMailParam's New "Content" Attribute Is Awesome
Ben, Mine is version 8 and tried to download the update but still did not recognized content attribute in cfmailparam. May be I installed a wrong update, so many of them not sure which one I need wit ... read »