-
-
Save chrislkeller/4709095 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var KpccClient; | |
KpccClient = (function() { | |
KpccClient.prototype.baseUrl = "http://scpr.org/api/content"; | |
function KpccClient(apiKey) { | |
this.apiKey = apiKey; | |
} | |
KpccClient.prototype.get = function(params) { | |
if (params == null) { | |
params = {}; | |
} | |
return $.ajax({ | |
type: "GET", | |
url: this.baseUrl, | |
data: { | |
query: params.query, | |
types: params.types, | |
limit: params.limit, | |
order: params.order | |
}, | |
dataType: "json" | |
}); | |
}; | |
return KpccClient; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = new KpccClient("someapikey"); | |
jqXHR = client.get({query: "Obama"}); | |
for (_i = 0, _len = jqXHR.responseText.length; _i < _len; _i++) { | |
obj = jqXHR.responseText[_i]; | |
console.log(obj.headline); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment