Skip to content

Instantly share code, notes, and snippets.

@bricker
Created February 4, 2013 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bricker/4709091 to your computer and use it in GitHub Desktop.
Save bricker/4709091 to your computer and use it in GitHub Desktop.
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;
})();
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