Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener("DOMContentLoaded", function(event) {
- function httpGetAsync(theUrl, callback)
- {
- var time = new Date().getTime() / 1000;
- var nonce = randomString(32);
- var xmlHttp = new XMLHttpRequest();
- xmlHttp.open("GET", theUrl, true);
- var params = JSON.stringify(
- {oauth_consumer_key:'TKk4q4d0R_ChTSTgfJe__g'},
- {oauth_token:'nXF2cUc5nwnGh06V8W8ZmIAt2B5WPzUY'},
- {oauth_signature_method:'hmac-sha1'},
- {oauth_signature:'WkVTrSYhI0oChU-uyvvuldJPK0A'},
- {oauth_timestamp:time},
- {oauth_nonce:nonce}
- );
- xmlHttp.setRequestHeader("Content-type", "application/json; charset=utf-8");
- //xmlHttp.setRequestHeader("Content-length", params.length);
- xmlHttp.setRequestHeader('Access-Control-Allow-Origin','*');
- //xmlHttp.setRequestHeader("Connection", "close");
- xmlHttp.onreadystatechange = function() {
- if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
- alert(http.responseText);
- };
- xmlHttp.send(params);
- }
- var randomString = function(length) {
- var text = "";
- var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- for(var i = 0; i < length; i++) {
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- }
- return text;
- };
- httpGetAsync('https://api.yelp.com/v2/search?term=food&location=San+Francisco');
- function something (text){
- console.log(text);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement