Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created May 20, 2012 21:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaronksaunders/2759602 to your computer and use it in GitHub Desktop.
Save aaronksaunders/2759602 to your computer and use it in GitHub Desktop.
Appcelerator Titanium Yelp API v2.0 Integration
//
// 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);
@wghirakawa
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment