Last active
December 16, 2015 01:19
-
-
Save calvinte/5354310 to your computer and use it in GitHub Desktop.
Alakazam images!
This file contains 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
alakazamPage = 1; | |
function alakazam(magic) { | |
var params = { | |
feature: 'popular', | |
consumer_key: '47HixZoC9snmw0OoJ6pHnky64gJ3WRBtx1IS3gRV', | |
callback: 'callback', | |
image_size: 3, | |
page: alakazamPage | |
}, | |
uriParams = '', | |
url = ''; | |
for (paramName in params) { | |
uriParams += '&' + paramName + '=' + params[paramName]; | |
} | |
var url = 'https://api.500px.com/v1/' + 'photos.jsonp' + '?' + uriParams; | |
// Construct JSONP request | |
tag = document.createElement('script'); | |
tag.src = url; | |
document.body.appendChild(tag); | |
callback = function (e) { | |
for (i = 0; i < e.photos.length; i++) { | |
var img = document.createElement('img'); | |
img.src = e.photos[i].image_url; | |
document.body.appendChild(img); | |
} | |
if (magic) magic(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment