본문 바로가기

Story/Javascript

Instagram api to show the latest popular images

반응형

Instagram api to show the latest popular images

call jsonp api from jquery

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
 
$(function() {
 
    $.ajax({
        type: "GET",
        dataType: "jsonp",
        cache: false,
        url: "https://api.instagram.com/v1/media/popular?client_id=84abd0d71cb14ad9885cf1dc59594144", 
        success: function(data) {
            for (var i = 0; i < 10; i++) {
                $("#pics").append("<a target='_blank' href='" + data.data[i].link + "'><img src='" + data.data[i].images.low_resolution.url + "'></img></a>");
            }
        }
    });
});

 
</script>
</head>
 
<body>
 
<div id="pics">
 
</div>
 
</body>
</html>

출처 : http://stackoverflow.com/questions/9732345/call-jsonp-api-from-jquery-nothing-shown

참고 : http://instagram.com/developer/

반응형