Skip to content

Instantly share code, notes, and snippets.

@wghirakawa
Forked from aaronksaunders/app.js
Created March 7, 2014 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wghirakawa/9404536 to your computer and use it in GitHub Desktop.
Save wghirakawa/9404536 to your computer and use it in GitHub Desktop.
//
// 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 = 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
Author

You double stringily the response. The response is already stringified via JSOAUTH in the latest version of JSOUTH

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