How to use the API Key?
Eriol
Registered Users Posts: 7 Beginner grinner
I'm trying to use this syntax to make an anonymous login:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.login.anonymously&APIKey=XXX
where XXX is the key. According to Firebug, the response is 200 OK, so the request was successful, but the response is empty.
Any idea what I am doing wrong? Thanks.
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.login.anonymously&APIKey=XXX
where XXX is the key. According to Firebug, the response is 200 OK, so the request was successful, but the response is empty.
Any idea what I am doing wrong? Thanks.
0
Comments
SmugMug API Developer
My Photos
Hi, I'm calling it through jQuery's $.getJSON() method.
(function($) {
$(document).ready(function(){
$.getJSON('http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.login.anonymously&APIKey=XXXXX', function(data) {
alert(data);
});
});
})(jQuery);
Something is wrong with the data returned to this method.
SmugMug API Developer
My Photos
Shouldn't the JSON just be of MIME type text?
I'll check my Javascript.
Hmm, I had expected the SmugMug JSON REST URL to behave like the Flickr REST URL. From what I can tell, Flickr returns text/plain as the MIME type while SmugMug returns application/JSON as the MIME type. I'm wondering if that is throwing things off.
EDIT: The JSON spec says the proper MIME type is application/json. I'm wondering if the jQuery library has issues with application/json.
$.ajax({
url: 'http://api.smugmug.com/services/api/json/1.2.2/?method=smugmug.login.anonymously&APIKey=XXXXX',
type: 'GET',
dataType: 'json',
success: function(data) {
console.log(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
},
complete: function(XMLHttpRequest, textStatus){
console.log(textStatus);
}
});
So, it looks like I can't use this API the way I wanted to. Oh well.
We support JSONP, you just need to send the Callback parameter defining the local JS function to call on return.
Cheers,
David
SmugMug API Developer
My Photos
http://www.dgrin.com/showthread.php?t=137990
Want faster uploading? Vote for FTP!
Hello Eriol,
not sure if you moved on to other things in the meantime. Reading your questions I vaguely remember a small bit of hobby code I did about 2 years ago. Using jQuery to pull picture URLs from a Smugmug albumb. All very hard coded for testing. This is How I went about it (and it works).
]
I output the images in a list of thumbnails that link to the larger images for a jquery lightbox. The code could probably we redone a lot nicer, but it works and should give you an idea.