Skip to content

Instantly share code, notes, and snippets.

@j0ni
Created April 6, 2016 21:37
Show Gist options
  • Save j0ni/69db281d9c150079099835563a2a6615 to your computer and use it in GitHub Desktop.
Save j0ni/69db281d9c150079099835563a2a6615 to your computer and use it in GitHub Desktop.
<html lang="en">
<head>
</head>
<body>
<table>
<thead>
<tr>
<th>Id</th>
<th>Title</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script>
function photoUrl(farm, server, id, secret) {
return "https://farm" + farm + ".staticflickr.com/" +
server + "/" + id + "_" + secret + ".jpg";
}
$(function () {
var apiKey = 'yorApiKey';
$.ajax({
url: 'https://api.flickr.com/services/rest/?format=json&nojsoncallback=1&method=flickr.photos.getRecent&api_key=' + apiKey,
dataType: 'json',
method: 'GET'
}).done(function (response) {
console.log(response);
response.photos.photo.forEach(function (photo) {
var url = photoUrl(photo.farm, photo.server, photo.id, photo.secret);
var tr = '<tr><td><img src="' + url + '"/></td><td>' + photo.title + '</td></tr>';
$('tbody').append(tr);
});
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment