Thanks Ryan, that worked. However if you only register a new app instagram, it goes in Sandbox Mode and public content is not available. You have to properly register your app with them and make a submission to go live. Other wise you can still use it but don't get access to public_content.
So if you use an access token gotten through a sandbox app, you'll get this response from any reqest you try to make:
{"pagination":{"deprecation_warning":"next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead"},"meta":{"code":200},"data":[]}
someone had this issue reported on stack overflow, and somebody replied with a valid access token which I'm still using... hehe
You also need to uncheck the Disable implicit OAuth in the security tab of your instagram client app if you're app client is live but still not working.
Last thing,
the images url from the JSON response have a query sring at the end that looks like this :
4532622_1878004650_n.jpg?ig_cache_key=MTIxODg4OTkyNzI3NDgzNzUxNw%3D%3D.2.l
You need to get rid of it, otherwise it on save on you're desktop. cause you know.. .jpg?ig_cache... is not a file format... (at least it did not work for me on windows)...
So I changed the getImagURL function by adding a second replace to pname... you can surely use a nicer regex that does this without repetition, but I was lazy.
function getImageURL(image){
var pname = imageurl[image].replace(/^.*(\\|\/|\:)/, '').replace(/(jpg\?.*)/,"jpg");
var pp = new XMLHttpRequest();
pp.open("GET",imageurl[image]);
pp._setRequestKey("filename_out",imagepath+pname);
pp.onreadystatechange= filewriteCallback;
pp.send();
outlet(0,pname);
}