Last active
April 28, 2022 02:58
-
-
Save trmtsy/1026378 to your computer and use it in GitHub Desktop.
InstagramのAPIを利用してポピュラーの写真を読み込みます。---client_id---にクライアントIDを入れて使う。
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Instagram API</title> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
function ajaxStart () { | |
$.ajax({ | |
url: "https://api.instagram.com/v1/media/popular", | |
data: {client_id: "---client_id---"}, | |
dataType: "jsonp", | |
error: function(xhr, textStatus, errorThrown) { | |
}, | |
success: function(data, textStatus, xhr) { | |
for (var i = 0, length = data.data.length; i < length; i++) { | |
var d = data.data[i]; | |
$('#loadArea').prepend($('<img>').attr('src', d.images.low_resolution.url)); | |
} | |
} | |
}); | |
} | |
</script> | |
</head> | |
<body id="content"> | |
<button onclick="javascript:ajaxStart();">ポピュラー読み込み</button> | |
<div id="loadArea"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment