Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@wghirakawa wghirakawa commented Mar 7, 2014

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