Javascript instagram api中的循环数组

Javascript instagram api中的循环数组,javascript,jquery,api,instagram,Javascript,Jquery,Api,Instagram,我正在尝试循环使用instagram api中的一个数组。数组是标记,之后我希望每个标记都附加到html中的li元素。我试过几种方法,比如在foor循环中使用for循环。现在我已经设置好了数组标记中的第一个元素,但是我希望每个标记都有自己的li标记,我需要循环遍历名为Tags的数组吗?谢谢这是我的密码: //instagram api example, this code makes you fetch images after searching specific hashtag $(docu

我正在尝试循环使用instagram api中的一个数组。数组是标记,之后我希望每个标记都附加到html中的li元素。我试过几种方法,比如在foor循环中使用for循环。现在我已经设置好了数组标记中的第一个元素,但是我希望每个标记都有自己的li标记,我需要循环遍历名为Tags的数组吗?谢谢这是我的密码:

//instagram api example, this code makes you fetch images after searching specific hashtag
$(document).ready(function () {
    var myId = "---";
    //sets so form doesnt override jquery
    $('#submit').click(function (event) {
        event.preventDefault();
    })
    $('#submit').click(searchInst);
    //shows a loading bar when press the btn
    // Setup the url for the API
    //var url = "https://api.instagram.com/v1/tags/"+input+"/media/recent?client_id=dff465e44a4d4026b554b3d7925643cc&callback=?&count=100";

    // Tell jQuery to fetch the data.
    // When it returns the data, it will call our `processImages` function 
    //$.getJSON(url, processImages);
    function searchInst() {
        $('.feed').empty()
        $('#load').append('<p>The images are loading..</p><br><img src="img/load.gif">')
        var input = $("#textInput").val()
        var url = 'https://api.instagram.com/v1/tags/' + input + '/media/recent?client_id=' + myId + '&callback=?&count=100'
        $.getJSON(url, processImages);
    };

    function processImages(chilibiff) {
        // The variable f represents the information we got back.
        var i = 0;
        for (var i = 0; i < chilibiff.data.length; i++) {
            var f = chilibiff.data[i]
            var imgSrc = f.images.standard_resolution.url
            var userImg = f.user.profile_picture
            var userName = f.user.username
            //tag for loop doesn't work, try code for in on your server
            var tags = f.tags[0]
            $('.feed').append('<img src="' + userImg + '" id="profile"><p>' + userName + '</p>')
            $('.feed').append('<img src="' + imgSrc + '">')
            $('.feed').append('<li>' + tags + '</li>')
        }
        $('#load').empty()
    }
});
//instagram api示例,此代码使您在搜索特定的标签后获取图像
$(文档).ready(函数(){
var myId=“--”;
//设置使表单不重写jquery
$(“#提交”)。单击(函数(事件){
event.preventDefault();
})
$(“#提交”)。单击(searchInst);
//按btn时显示加载条
//设置API的url
//变量url=”https://api.instagram.com/v1/tags/“+input+”/media/recent?client_id=dff465e44a4d4026b554b3d7925643cc&callback=?&count=100”;
//告诉jQuery获取数据。
//当它返回数据时,它将调用'processImages'函数
//$.getJSON(url、processImages);
函数searchInst(){
$('.feed').empty()
$(“#加载”)。追加(“正在加载图像。


”) 变量输入=$(“#文本输入”).val() var url='1〕https://api.instagram.com/v1/tags/“+input+”/media/recent?客户端_id=”+myId+“&callback=?&count=100” $.getJSON(url、processImages); }; 函数processImages(chilibif){ //变量f表示我们得到的信息。 var i=0; 对于(变量i=0;i')) $('.feed')。追加('') $('.feed').append('
  • '+tags+'
  • ')) } $('#load').empty() } });
    好的,这样可以解决问题。在循环结果之后,需要循环数组

        //instagram api example, this code makes you fetch images after searching specific hashtag
    
        $(document).ready(function() {
    
        var myId = "------";
    
        //sets so form doesnt override jquery
        $('#submit').click(function(event) {
    event.preventDefault();
    })
    
          $('#submit').click(searchInst);
    
          //shows a loading bar when press the btn
    
         // Setup the url for the API
        //var url = "https://api.instagram.com/v1/tags/"+input+"/media/recent?   client_id=dff465e44a4d4026b554b3d7925643cc&callback=?&count=100";
    
        // Tell jQuery to fetch the data.
        // When it returns the data, it will call our `processImages` function 
        //$.getJSON(url, processImages);
    
        function searchInst() {
    $('.feed').empty()
    $('#load').append('<p>The images are loading..</p><br><img src="img/load.gif">')
    var input = $("#textInput").val()
    var url = 'https://api.instagram.com/v1/tags/' + input + '/media/recent?client_id=' +    myId + '&callback=?&count=100'
    $.getJSON(url, processImages);
        };
    
        function processImages(chilibiff) {
        // The variable f represents the information we got back.
        for (var i = 0; i < chilibiff.data.length; i++) {
        var f = chilibiff.data[i]
        var imgSrc = f.images.standard_resolution.url
        var userImg = f.user.profile_picture
        var userName = f.user.username
        //tag for loop doesn't work, try code for in on your server
        $('.feed').append('<img src="' + imgSrc + '">')
        $('.feed').append('<img src="' + userImg + '" id="profile">' + '<p><a   href="http://www.instagram.com/' + userName + '" target="_blank">' + userName + '</a></p>')
    
      for (var x=0; x < f.tags.length; x++) {
      var tag = f.tags[x]
      $('.feed').append('<li>' + tag + '</li>')
        }
    
        }
    
        $('#load').empty()
        }
    
    
        });
    
    //instagram api示例,此代码使您在搜索特定的标签后获取图像
    $(文档).ready(函数(){
    var myId=“----”;
    //设置使表单不重写jquery
    $(“#提交”)。单击(函数(事件){
    event.preventDefault();
    })
    $(“#提交”)。单击(searchInst);
    //按btn时显示加载条
    //设置API的url
    //变量url=”https://api.instagram.com/v1/tags/“+input+”/media/recent?client_id=dff465e44a4d4026b554b3d7925643cc&callback=?&count=100”;
    //告诉jQuery获取数据。
    //当它返回数据时,它将调用'processImages'函数
    //$.getJSON(url、processImages);
    函数searchInst(){
    $('.feed').empty()
    $(“#加载”)。追加(“正在加载图像。


    ”) 变量输入=$(“#文本输入”).val() var url='1〕https://api.instagram.com/v1/tags/“+input+”/media/recent?客户端_id=”+myId+“&callback=?&count=100” $.getJSON(url、processImages); }; 函数processImages(chilibif){ //变量f表示我们得到的信息。 对于(变量i=0;i')) 对于(var x=0;x'+tag+'')) } } $('#load').empty() } });
    如果您能从API提供一些json数据,这将更容易理解。但您也使用了jQuery,所以它不是。以下是json数据: