summaryrefslogtreecommitdiffabout
path: root/content
Side-by-side diff
Diffstat (limited to 'content') (more/less context) (ignore whitespace changes)
-rw-r--r--content/flickr.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/content/flickr.js b/content/flickr.js
index e09d5f0..545144c 100644
--- a/content/flickr.js
+++ b/content/flickr.js
@@ -115,12 +115,32 @@ Flickr.prototype = {
pstr += pn+params[pn];
rv += pn+'='+params[pn]+'&';
}
rv += 'api_sig='+this.api_sig(pstr);
return rv;
},
+ api_call_json: function(params,on_success,on_failure) {
+ if(params.auth_token=='default') params.auth_token=this.token;
+ params.format = 'json'; params.nojsoncallback=1;
+ var x = new XMLHttpRequest();
+ x.open("GET",this.api_call_url(params));
+ x.onreadystatechange=function() {
+ if(x.readyState!=4) return false;
+ if(x.status==200) {
+ var rsp=JSON.parse(x.responseText);
+ if(rsp.stat=='ok')
+ on_success && on_success(x,rsp);
+ else
+ on_failure && on_failure(rsp,rsp.stat,rsp.code,rsp.message);
+ }else
+ on_failure && on_failure(x);
+ return true;
+ };
+ x.send(null);
+ return true;
+ },
api_call: function(params, on_success, on_failure) {
if(params.auth_token == 'default')
params.auth_token = this.token;
var x = new XMLHttpRequest();
x.open("GET",this.api_call_url(params));
x.onreadystatechange=function() {