Update to Using ColdFusion to Create a Twitter/Google Maps Mashup
Posted At : May 7, 2009 11:15 PM | Posted By : Bob Silverberg
Related Categories: ColdFusion
That's what I get for banging something out in a couple of hours, and not RTFMing. It turns out that you can get a user's friends via the Twitter API without authenticating. It's just that the ColdFusion Twitter Lib doesn't currently support it. So I made one small change to a method in the library (sorry Pedro), allowing me to request a user's friends without authentication, and changed my code and demo.
So you can now feel safe running the demo.
I discovered a couple of other new things, when I took the time to dig a bit deeper.
The first is that when you ask Twitter's API for a list of friends it will only return 100 at a time, so you need to do paging.
The second is that Google's Geocode API isn't keen on getting dozens of requests in a short period of time. It was rejecting a lot of calls, and therefore the locations were not being reported and the markers were missing from the map. The only way I could find around that, in the limited time that I've devoted to this, was to use ColdFusion's Sleep() function to wait between API calls. Of course that has slowed the whole thing down tremendously, but at least I'm getting more markers on the map.
The new code is attached to this post.
Accepted the 5 lines that were changed, feel liberates to contact me or use my blog (http://blog.pcsilva.com/en) to suggest new alterations, or to indicate applications as this
+++ trunk/Twitter.cfc Thu May 7 21:00:39 2009
@@ -42,7 +42,9 @@
- <cfset userid = temp.user.id.xmltext />
+ <cfif StructKeyExists(temp,"user")>
+ <cfset userid = temp.user.id.xmltext />
+ </cfif>
@@ -97,7 +99,7 @@
- <cfset values = ListAppend(values,'#key#=#arguments.options[key]#','&') />
+ <cfset values = ListAppend(values,'#lcase(key)#=#arguments.options[key]#','&') />
@@ -405,7 +407,19 @@
- <cfreturn execute(uri, true) />
+ <cfreturn execute(uri, false) />