Skip to main content

Yelp api via Coldfusion and oAuth

What should have been a fairly easy implementation turned into several frustrating hours. I was using the old Yelp API that is accessed simply by passing your yelp key in the url. But, I wanted to take advantage of some of the new functionality only available in their API version 2.0. Unfortunately Yelp API v2 requires an oAuth key/signature type access.

Having already written similar code to access the Amazon web services with a signature I thought this would be a simple as reusing some existing code. Man was I wrong. Turns out a "correctly" implemented version of oAuth is much less tolerant than AWS is. Simple things, such as what characters in the URL must be encoded, invalidated the Yelp signature.

After much searching and screwing around with various proposed implementations it became clear that the easiest and best implementation was to use the Java library provided by Yelp and simply access it from Coldfusion.

To make this process easier I've consolidated the base java functions and wrapped them in one easy to call class. You simply invoke it with your Yelp keys and it does all the dirty work. To make it work you need to download and place the 3 java JAR files in your Coldfusion java classpath (or add a class path via CF Administrator). and then call the code like this (replace the "..." key values with your actual key values:

cfset consumerKey = "...">
cfset consumerSecret = "...">
cfset token = "...">
cfset tokenSecret = "...">

cfset yelp = CreateObject("java", "com.northbrook.yelp.Yelp").init(consumerKey, consumerSecret, token, tokenSecret)>
cfset yelp.addQueryStringParameter("location", "Northbrook*IL")>
cfset yelp.addQueryStringParameter("limit", "25")>
cfset result = yelp.query()>

cfdump var = "#result#">


Download three JARS and a sample .CFM here:
https://docs.google.com/leaf?id=0B-wcv3xk3UO2NjI3MTI1NmYtMmI2Yy00NzQxLTlkNzEtN2Y4ZjVjYTk5MGRk&hl=en_US

https://docs.google.com/leaf?id=0B-wcv3xk3UO2NTIzNDg5MGUtM2ExMS00MTllLWJjYTItNTQ4M2U0NjQ4MTBh&hl=en_US

https://docs.google.com/leaf?id=0B-wcv3xk3UO2MmQzNDA0YzAtYzI1Yy00N2NjLWFmNmItNjk2YmJjMmFjMjZl&hl=en_US

https://docs.google.com/leaf?id=0B-wcv3xk3UO2ZTY0ZDI2MjMtNmVlNi00YzI5LTgxMDMtYTgyNjA4ODM0NjY4&hl=en_US

Popular posts from this blog

Dride Zero - Dashcam on Steroids

I took part in a Kickstarter project to build "The ultimate Dashcam".  One with front and back cameras that would shoot in HD, was durable and low power, and would upload video clips to the cloud with the push of a button.  We'll after waiting more than a year, they did just that.  I received my Dride Zero a couple of days ago and, other than an initial rocky "Setup" process, it has been working fantastic. This post isn't so much to talk about the Dride, you can get that information from them at https://dride.io.   This is more for those people who might run into the same issues with Setup that I had.  Hopefully this will save them some of the time I wasted trying to figure it out. Dride Zero Getting Started 1) Unpack from the shipping box.   To get started all you need at first is the Dride Camera, the powercord that has the cigarette lighter connector, and a 16Gb type 10 Micro SD card. 2) Insert the 16Gb Micro SD card in the slot...

Troubleshooting a Discourse Update on DigitalOcean: Resolving Unresolvable Errors

For the past three years, I've maintained a Discourse server on a DigitalOcean Droplet. Recently, I decided to update it with some of the latest Discourse features. What I anticipated to be a straightforward update process turned into several days of frustrating setbacks. The version of Discourse I was running was already three years old, so I assumed that running the built-in "Update" feature would suffice. However, after clicking the update button, the progress bar sluggishly crawled forward over the next half hour, only to display the dreaded message: "Error – Update Failed." The logs provided little to no help, but based on my experience with other software updates via GIT, I suspected that the failure might be due to the repository head still being called "Master." In recent years, there has been a shift away from using "Master" as the repository head, with "Main" becoming the preferred term. Despite trying several methods ...

Ethereum Merge - So What?

Artwork by Steven Grundy The long awaited Ethereum "Merge" is finally upon us.  I've heard people say "So what".   So what?  I think they don't understand the implications of the merge.  Either that or they really are betting against Ethereum. I think this upgrade is probably the biggest thing for Ethereum since smart contracts first came out.  This change has the possibility of upsetting the apple cart in terms of Ethereum and BTC.  That's a big claim, but I really think it's possible. The Ethereum Merge has been set for the week of September 19th, 2022.  The merge is when the Ethereum execution layer will be joined with the new proof of stake consensus layer.  What does that mean and why should I care? What it means is that Ethereum will be changing from an energy intensive Crypto coin like all others to a 99% more efficient crypto coin like only a few have done.  Right now Ethereum is mined just like BTC and a host of other Crypto cur...