Turning Up the Heat with ColdFusion?

Adobe paid for a white paper that analyse and state some good (and hide some obvious, but not pleasant) findings about ColdFusion. It’s a nice paper on the history and features of ColdFusion, but to me, is more of a sad and nostalgic paper about how powerful it could be if different strategic path was adopted by Adobe some time ago (circa CF7-8 era) – but that’s a different (and old) history.

5-7-2013 12-55-01 PM

The white paper states:

ColdFusion has remained popular among its loyal users and has continued to attract new developers interested in its unique blend of capabilities

ColdFusion continues to attract new developers? Seriously? That’s funny. For a long time I’ve being looking and I couldn’t find not a single book about ColdFusion on the major physical bookstores in the US, with some rare exceptions (maybe that’s because books are a thing of the past, right?). What to say about the attraction of new developers? I’m yet to see a developer that pick ColdFusion as a language/technology by choice instead of doing it because it’s employee asks them to do (legacy code maintenance?). When I read this statement, I felt like:

CFML_leads


Easy twitter authentication with ColdFusion

As you might know, Twitter API 1.0 will be soon deprecated and anonymous or basic HTTP-authenticated calls/requests won’t be allowed. OAuth can be cumbersome sometimes, specially if all you need is basic querying the API (such as GET search/tweets). Maybe that’s why Twitter API 1.1 introduced a new authentication method that simplifies the process of authenticating requests. Starting with the 1.1, some endpoints that doesn’t require user personification/identification can be accessed using the new Application-only authentication. This new method is much simpler to work with. To exemplify, take a look on a very basic search for the #ColdFusion hashtag against Twitter API 1.1:

<cfset consumerKey = "YOUR APP CONSUMER KEY">
<cfset consumerSecret = "YOUR APP CONSUMER SECRET">
<cfset bearerToken = ToBase64(consumerKey & ":" & consumerSecret)>
<cfset authorization = "Basic " & bearerToken>

<cfhttp url="https://api.twitter.com/oauth2/token" method="post" charset="utf-8">
	<cfhttpparam type="header" name="Authorization" value="#authorization#">
	<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded;charset=UTF-8">
	<cfhttpparam type="body" value="grant_type=client_credentials">
</cfhttp>

<cfset bearerTokenResponse = DeserializeJSON(cfhttp.fileContent)>
<cfset authorization2 = "Bearer " & bearerTokenResponse.access_token>

<cfhttp url="https://api.twitter.com/1.1/search/tweets.json" method="get" charset="utf-8">
	<cfhttpparam type="header" name="Authorization" value="#authorization2#">
	<cfhttpparam type="url" name="q" value="%23ColdFusion">
</cfhttp>

<cfoutput>#cfhttp.fileContent#</cfoutput>

Of course, you still need to register a Twitter App (more about it here). Need to use a Twitter resource that doesn’t support Application-only authentication? Then you should try the excellent (monkeh)Tweet Twitter API.

Enjoy!