Skip to content

Instantly share code, notes, and snippets.

@wilt00
Last active June 28, 2019 03:01
Show Gist options
  • Save wilt00/eacad339f7ccc27134c3190f0b6fb4c9 to your computer and use it in GitHub Desktop.
Save wilt00/eacad339f7ccc27134c3190f0b6fb4c9 to your computer and use it in GitHub Desktop.
Benstagram
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<title>Page Title</title>
<style>
#instagram_feed {
margin: 0;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.feed_item {
padding: 10px;
}
</style>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<div id="instagram_feed"></div>
<script>
function ig(obj) {
console.log(obj);
if (obj.meta.code !== 200) {
console.log("Return code was:" + toString(obj.meta.code));
return;
}
const feed = document.getElementById("instagram_feed");
obj.data.map(function(pic) {
const img = document.createElement("img");
img.src = pic.images.thumbnail.url;
const a = document.createElement("a");
a.href = pic.link;
a.target = "_blank";
a.appendChild(img);
const item = document.createElement("div");
item.classList.add("feed_item");
item.appendChild(a);
feed.appendChild(item);
});
if (obj.pagination.next_url) {
const nextPage = document.createElement('script');
nextPage.src = obj.pagination.next_url;
document.body.appendChild(nextPage);
}
}
</script>
<script src="https://api.instagram.com/v1/users/self/media/recent/?access_token=15402754604.0241b45.d34780d754b746468132680c4f120db0&callback=ig"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment