Created
May 20, 2012 21:28
-
-
Save aaronksaunders/2759602 to your computer and use it in GitHub Desktop.
Appcelerator Titanium Yelp API v2.0 Integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Aaron K. Saunders | |
// | |
// http://www.clearlyinnovative.com | |
// http://blog.clearlyinnovative.com | |
// @aaronksaunders | |
// | |
// SEE http://bytespider.github.com/jsOAuth/ for jsOAuth.js | |
// | |
Ti.include("jsOAuth.js"); | |
var auth = { | |
// Update with your auth tokens | |
consumerKey : "xxxxxxxxxxx", | |
consumerSecret : "xxxxxxxxxxxxxxx", | |
accessTokenKey : "xxxxxxxxxxxxxxxxxx", | |
accessTokenSecret : "xxxxxxxxxxxxxxxxx", | |
serviceProvider : { | |
signatureMethod : "HMAC-SHA1" | |
} | |
}; | |
var oauth = OAuth(auth); | |
var args = { | |
params : {}, | |
method : "GET" | |
}; | |
var options = { | |
'method' : "GET", | |
//'headers' : headers, | |
'url' : 'http://api.yelp.com/v2/business/bay-to-breakers-12k-san-francisco', | |
'data' : (args.method === 'PUT' || args.method === 'POST') ? JSON.stringify(args.params) : args.params, | |
'success' : function(data) { | |
var response = JSON.stringify(data); | |
Ti.API.info('success - response ' + response); | |
if(args.success !== undefined) { | |
args.success(data); | |
} | |
}, | |
'failure' : function(data) { | |
var response = JSON.stringify(data); | |
Ti.API.info('failure - response ' + response); | |
if(args.success !== undefined) { | |
args.error(data) | |
} | |
} | |
} | |
// Make the request | |
oauth.request(options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry i forked it thinking that their were pull request on GIST but anyways. on Line 35 you are stringifying it when it is already being stringified by jsOauth.js as per the most recent file. I spent all day trying to figure out why my double quotes were being escaped. Hope this helps someone else. Paying it back! Thanks Aaron