title: Yelp API and AngularJS
body: <p>I'm trying to call the Yelp API using AngularJS, but I'm having trouble. I keep getting a 400 bad request and I don't know why.</p>
  
  <p>Yelp API documentation:</p>
  
  <p><a href="http://www.yelp.com/developers/documentation/v2/authentication">http://www.yelp.com/developers/documentation/v2/authentication</a>
  <a href="http://www.yelp.com/developers/documentation/v2/search_api">http://www.yelp.com/developers/documentation/v2/search_api</a></p>
  
  <p>Page containing Yelp API generated keys:</p>
  
  <p><a href="http://gyazo.com/fa918329eb0cde18a5db242d1d0b0b0e">http://gyazo.com/fa918329eb0cde18a5db242d1d0b0b0e</a></p>
  
  <p>This is the snippet of my code doing the call:</p>
  
  <pre><code>function randomString(length, chars) {
  var result = '';
  for (var i = length; i &gt; 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
  return result;
  }
  
  app.factory("MyYelpAPI", function($http) {
  return {
      "retrieveYelp": function(name, callback) {
          $http.jsonp("http://api.yelp.com/v2/search?term=food&amp;location=San+Francisco&amp;callback=JSON_CALLBACK",
              {
                  params: {
                      oauth_consumer_key: /* Consumer Key */,
                      oauth_token: /* Token */,
                      oauth_signature_method: "hmac-sha1",
                      oauth_signature: /* Token Secret */,
                      oauth_timestamp: new Date().getTime(),
                      oauth_nonce: randomString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
                  }
              }
          ).success(callback);
      }
  }
  });
  </code></pre>