如何从instagram.com/(username)/media获取Instagram ID

时间:2017-04-26 19:58:01

标签: jquery json ajax api instagram

当我去

https://www.instagram.com/35mmslrs/media/

我得到以下json:

{"items": [{"id": "1475526779741400854_4248709454", "code": "BR6H8nbD-8W", "user": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, "images": {"thumbnail": {"width": 150, "height": 150, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s150x150/e35/17333441_1870235779900721_8098626763250204672_n.jpg"}, "low_resolution": {"width": 320, "height": 320, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s320x320/e35/17333441_1870235779900721_8098626763250204672_n.jpg"}, "standard_resolution": {"width": 640, "height": 640, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/17333441_1870235779900721_8098626763250204672_n.jpg"}}, "created_time": "1490116520", "caption": {"id": "17854517083135209", "text": "International shipping now available #35mm #analogphotography #35mmslr #filmisnotdead www.35mmslr.co", "created_time": "1490116520", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, "likes": {"data": [{"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, {"id": "11323762", "full_name": "Katherine Brennan", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/16123632_1933844573510439_3412022908724183040_n.jpg", "username": "katieimperatrix"}, {"id": "4844944", "full_name": "\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800  \u2800\u219e Martina \u21a0", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17882566_439840559688446_784181876297302016_a.jpg", "username": "martinafbtt"}, {"id": "961783324", "full_name": "\ud83c\uddf7\ud83c\uddfa", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15056723_1747039282288282_874983493593989120_a.jpg", "username": "geragerain"}], "count": 54}, "comments": {"data": [], "count": 0}, "can_view_comments": true, "can_delete_comments": false, "type": "image", "link": "https://www.instagram.com/p/BR6H8nbD-8W/", "location": null, "alt_media_url": null}, {"id": "1401726211293696218_4248709454", "code": "BNz7pAAg9Da", "user": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, "images": {"thumbnail": {"width": 150, "height": 150, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s150x150/e35/15306751_640436889461963_2111857895007059968_n.jpg"}, "low_resolution": {"width": 320, "height": 320, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s320x320/e35/15306751_640436889461963_2111857895007059968_n.jpg"}, "standard_resolution": {"width": 640, "height": 640, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/15306751_640436889461963_2111857895007059968_n.jpg"}}, "created_time": "1481318807", "caption": {"id": "17855415499092482", "text": "#35mmslr #yashica #tlelectro #yashicatlelectro #35mmslr #photographyislife #photography #analoguephotography #analogphotography #shootfilm", "created_time": "1481318807", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, "likes": {"data": [{"id": "1441645", "full_name": "Sebastian Milla", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/14334702_188150708275428_6005698051837001728_a.jpg", "username": "sebamilla"}, {"id": "2960884547", "full_name": "\u7d50\u5ddd \u3068\u307e", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/18013450_1889457127968885_777923567781150720_a.jpg", "username": "toma_yukawa"}, {"id": "218972459", "full_name": "Dj Dyxanin", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/13256998_1755246684762571_791743144_a.jpg", "username": "dj_dyxanin"}, {"id": "1432706732", "full_name": "\u041a\u043b\u0443\u0431 \"\u041c\u0401\u0414\" | \u0420\u043e\u0441\u0442\u043e\u0432-\u043d\u0430-\u0414\u043e\u043d\u0443", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/15534731_1070414433080629_1014595571668746240_n.jpg", "username": "night_med"}], "count": 174}, "comments": {"data": [{"id": "17845071226188675", "text": "Pretty Cool", "created_time": "1481322530", "from": {"id": "1668256481", "full_name": "Danny Ace Films", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/11201799_1426104567707683_1237452488_a.jpg", "username": "dannyacefilms"}}, {"id": "17874496738004160", "text": "\ud83d\udc97 this!", "created_time": "1488559653", "from": {"id": "3482777089", "full_name": "\ud83c\udf7cDarcy\ud83c\udf80", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/18013614_304259049995864_4215955363930832896_a.jpg", "username": "milkfluffs"}}, {"id": "17861203633086239", "text": "\uc88b\uc740 \uc18c\ud1b5 \ub098\ub204\uba74 \uc88b\uaca0\uc2b5\ub2c8\ub2e4~~\ub9de\ud314\uc694\uccad \ub4dc\ub824\uc694~!", "created_time": "1488770498", "from": {"id": "4583488304", "full_name": "\uc54c\ub9f9\uac00\uc871\uc758 \uc721\uc544 \uc18c\ud1b5 \uc778\uc2a4\ud0c0\uadf8\ub7a8\uc785\ub2c8\ub2e4.", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17493846_396285350751182_4790574696250736640_a.jpg", "username": "almeng.mom_papa"}}], "count": 3}, "can_view_comments": true, "can_delete_comments": false, "type": "image", "link": "https://www.instagram.com/p/BNz7pAAg9Da/", "location": null, "alt_media_url": null}, {"id": "1401725208695627682_4248709454", "code": "BNz7aaRA1-i", "user": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, "images": {"thumbnail": {"width": 150, "height": 150, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s150x150/e35/15306779_378194792529242_128925490772705280_n.jpg"}, "low_resolution": {"width": 320, "height": 320, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s320x320/e35/15306779_378194792529242_128925490772705280_n.jpg"}, "standard_resolution": {"width": 640, "height": 640, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/15306779_378194792529242_128925490772705280_n.jpg"}}, "created_time": "1481318687", "caption": {"id": "17846495476133590", "text": "#pentax #p30n #pentaxp30n #photography #photographyislife #comingsoon #35mm #slr # #analogphotography #analoguephotography #shootfilm  #35mmslr", "created_time": "1481318687", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, "likes": {"data": [{"id": "3502462543", "full_name": "Mael Antschel", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/16464802_1878968585678664_4659899818053730304_a.jpg", "username": "mael_antschel"}, {"id": "356227053", "full_name": "Toronto Car Spotters", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/11375272_1114030555293144_316460465_a.jpg", "username": "torontocarspotters"}, {"id": "3905987301", "full_name": "\u30a2\u30e4\u30f3 \u30d0\u30f3\u30af\u30fc\u30d0\u30fc", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17126167_652759384927917_9214350951970766848_a.jpg", "username": "ayankhay"}, {"id": "198677271", "full_name": "Daphne Booth \ud83c\udfb6", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17333200_103777563493869_3783076467844317184_a.jpg", "username": "crystalvoice__"}], "count": 93}, "comments": {"data": [{"id": "17862899563092162", "text": "Love pentax One of my favourites was the P30, i had both super and program A's as well, still use the K1000 now and again", "created_time": "1490895560", "from": {"id": "596163599", "full_name": "Mick", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/16123172_374953542882576_207716184781488128_n.jpg", "username": "troupemick"}}, {"id": "17852223016168905", "text": "@troupemick yeah i' recently got a pentax me super , just finished cleaning it will be taking it for a test drive this weekend", "created_time": "1490900278", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, {"id": "17875534627001784", "text": "@35mmslrs I have 3 1970's takumar prime lenses I use on a Fuji Xpro1 and a Fuji Xe2 they work great", "created_time": "1490900647", "from": {"id": "596163599", "full_name": "Mick", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/16123172_374953542882576_207716184781488128_n.jpg", "username": "troupemick"}}, {"id": "17864885692115803", "text": "@troupemick \ud83d\udc4c", "created_time": "1490902992", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}], "count": 4}, "can_view_comments": true, "can_delete_comments": false, "type": "image", "link": "https://www.instagram.com/p/BNz7aaRA1-i/", "location": null, "alt_media_url": null}, {"id": "1401721881723370174_4248709454", "code": "BNz6p_yA3q-", "user": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, "images": {"thumbnail": {"width": 150, "height": 150, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s150x150/e35/15258715_668767163298186_970528945218781184_n.jpg"}, "low_resolution": {"width": 320, "height": 320, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s320x320/e35/15258715_668767163298186_970528945218781184_n.jpg"}, "standard_resolution": {"width": 640, "height": 640, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/15258715_668767163298186_970528945218781184_n.jpg"}}, "created_time": "1481318291", "caption": {"id": "17866752562026068", "text": "#canont50 #canon #t50 #analogphotography #analoguephotography #photographyislife #35mm #slr #photography #comingsoon", "created_time": "1481318291", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, "likes": {"data": [{"id": "4020498418", "full_name": "Mairead Lane", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/15625276_1011937432245157_9031888973026295808_a.jpg", "username": "maireadlane_photography"}, {"id": "309394285", "full_name": "T\u00f8ri Gjendal", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/14564889_1104623199615344_2221324628423344128_a.jpg", "username": "torigjendalphotography"}, {"id": "3734009033", "full_name": "Tom Finn", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/15056677_1329640207068449_4706076617770795008_a.jpg", "username": "tommy2fin"}, {"id": "1499658142", "full_name": "Hamzeh Zahran", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17125475_405999226427839_5700720584585904128_a.jpg", "username": "hamzeh_zahran"}], "count": 77}, "comments": {"data": [], "count": 0}, "can_view_comments": true, "can_delete_comments": false, "type": "image", "link": "https://www.instagram.com/p/BNz6p_yA3q-/", "location": null, "alt_media_url": null}, {"id": "1401711579162213550_4248709454", "code": "BNz4UExg_yu", "user": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, "images": {"thumbnail": {"width": 150, "height": 150, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s150x150/e35/15276745_1034706399988644_7780349384306196480_n.jpg"}, "low_resolution": {"width": 320, "height": 320, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s320x320/e35/15276745_1034706399988644_7780349384306196480_n.jpg"}, "standard_resolution": {"width": 640, "height": 640, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/15276745_1034706399988644_7780349384306196480_n.jpg"}}, "created_time": "1481317063", "caption": {"id": "17856432454129307", "text": "#35mmslr #comingsoon #pentax #lomography #analogphotography  #photography #photographyislife #35mm #slr", "created_time": "1481317063", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, "likes": {"data": [{"id": "3734009033", "full_name": "Tom Finn", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/15056677_1329640207068449_4706076617770795008_a.jpg", "username": "tommy2fin"}, {"id": "1049205127", "full_name": "Nomad Junkies", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/12950325_626941270794315_1029526213_a.jpg", "username": "nomadjunkies"}, {"id": "386409657", "full_name": "William Stubbs", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/15534657_183412972127561_6843086403903946752_a.jpg", "username": "stormshack"}, {"id": "1564526031", "full_name": "Alessio \u219f", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17268289_222236771585271_4240153123777150976_a.jpg", "username": "lin.alessio"}], "count": 61}, "comments": {"data": [{"id": "17845276987161238", "text": "Great picture!", "created_time": "1481322579", "from": {"id": "48916724", "full_name": "MAGNUS BERG", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/14709546_318852965166781_8484688939557322752_a.jpg", "username": "maagnusberg"}}], "count": 1}, "can_view_comments": true, "can_delete_comments": false, "type": "image", "link": "https://www.instagram.com/p/BNz4UExg_yu/", "location": null, "alt_media_url": null}, {"id": "1401675758321124239_4248709454", "code": "BNzwK0BAcOP", "user": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, "images": {"thumbnail": {"width": 150, "height": 150, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s150x150/e35/14712308_187189691746415_840525215791316992_n.jpg"}, "low_resolution": {"width": 320, "height": 320, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s320x320/e35/14712308_187189691746415_840525215791316992_n.jpg"}, "standard_resolution": {"width": 640, "height": 640, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/14712308_187189691746415_840525215791316992_n.jpg"}}, "created_time": "1481312793", "caption": {"id": "17867670061060082", "text": "Website coming soon #zenit #zenite #35mmslr #35mm #slr #photography #photographyislife #comingsoon", "created_time": "1481312793", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, "likes": {"data": [{"id": "4032978324", "full_name": "", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/15535426_785828691568545_695779337537847296_n.jpg", "username": "allsenseofficial"}, {"id": "3566227389", "full_name": "Mark Ochinero", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/13731118_1438215682871807_1707724756_a.jpg", "username": "mark.ochinero"}, {"id": "8640413", "full_name": "R             \u00d8              A", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17663666_1893030197639080_528606716317663232_a.jpg", "username": "gonorroa"}, {"id": "1708839332", "full_name": "Nick Bridges", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/16906174_218470511959700_182857403698511872_a.jpg", "username": "hmsstfu"}], "count": 56}, "comments": {"data": [], "count": 0}, "can_view_comments": true, "can_delete_comments": false, "type": "image", "link": "https://www.instagram.com/p/BNzwK0BAcOP/", "location": null, "alt_media_url": null}, {"id": "1401674197847203670_4248709454", "code": "BNzv0Gtg19W", "user": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, "images": {"thumbnail": {"width": 150, "height": 150, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s150x150/e35/15259129_578281665706174_3437096210538692608_n.jpg"}, "low_resolution": {"width": 320, "height": 320, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s320x320/e35/15259129_578281665706174_3437096210538692608_n.jpg"}, "standard_resolution": {"width": 640, "height": 640, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/15259129_578281665706174_3437096210538692608_n.jpg"}}, "created_time": "1481312607", "caption": {"id": "17856319942124710", "text": "Yashica 35mm Slrs #lomography #photographyislife #photography #35mm #slr #yashica", "created_time": "1481312607", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, "likes": {"data": [{"id": "25050195", "full_name": "Michael Malone", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17077220_261644194288662_3939655032537874432_a.jpg", "username": "themichaelmalone"}, {"id": "4032978324", "full_name": "", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/15535426_785828691568545_695779337537847296_n.jpg", "username": "allsenseofficial"}, {"id": "325397076", "full_name": "Krish", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/13402273_1789155934649636_275296153_a.jpg", "username": "krishm47"}, {"id": "3261646810", "full_name": "Laurence Wong", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/13298025_501185293400331_380224953_a.jpg", "username": "laurence.wong.photography"}], "count": 34}, "comments": {"data": [{"id": "17853815344141361", "text": "Electro 35 \ud83d\ude1c", "created_time": "1489791272", "from": {"id": "31531777", "full_name": "JAVIER GONZALEZ", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17438327_437456803269682_8163907972636868608_a.jpg", "username": "javiergonzlz"}}], "count": 1}, "can_view_comments": true, "can_delete_comments": false, "type": "image", "link": "https://www.instagram.com/p/BNzv0Gtg19W/", "location": null, "alt_media_url": null}, {"id": "1401673482642763057_4248709454", "code": "BNzvpsoAa0x", "user": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}, "images": {"thumbnail": {"width": 150, "height": 150, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s150x150/e35/15337197_120415831782025_3572291992786305024_n.jpg"}, "low_resolution": {"width": 320, "height": 320, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s320x320/e35/15337197_120415831782025_3572291992786305024_n.jpg"}, "standard_resolution": {"width": 640, "height": 640, "url": "https://scontent-lht6-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/15337197_120415831782025_3572291992786305024_n.jpg"}}, "created_time": "1481312521", "caption": {"id": "17868203767001335", "text": "35mmSLR website coming soon #canon #ae1 #canonae1 #35mmslr #35mm #slr #photography #photographyislife #lomography", "created_time": "1481312521", "from": {"id": "4248709454", "full_name": "35mmslr", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg", "username": "35mmslrs"}}, "likes": {"data": [{"id": "3683409996", "full_name": "SkyCanvas.ca", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/14540665_1781831028773156_6462693245125132288_a.jpg", "username": "skycanvas.ca"}, {"id": "3261646810", "full_name": "Laurence Wong", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/13298025_501185293400331_380224953_a.jpg", "username": "laurence.wong.photography"}, {"id": "1564905", "full_name": "Valeria Podoynitsyna", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/13531943_149242682151262_2029555677_a.jpg", "username": "eyeventure"}, {"id": "476317739", "full_name": "\u274c CUENTA MUERTA \u274c", "profile_picture": "https://scontent-mia1-2.cdninstagram.com/t51.2885-19/11906329_960233084022564_1448528159_a.jpg", "username": "sansfiltro"}], "count": 77}, "comments": {"data": [{"id": "17851893901154043", "text": "The one \u0026 only \ud83d\udc4c", "created_time": "1489725376", "from": {"id": "1128202922", "full_name": "Carter A.", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/17332524_1387075421315448_1408477912759271424_a.jpg", "username": "artoflions"}}, {"id": "17866795414073057", "text": "My favorite", "created_time": "1490143435", "from": {"id": "3836934", "full_name": "JK Blackwell", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/1389116_736143539829927_1749522359_a.jpg", "username": "twoguineapigs"}}, {"id": "17851802227176829", "text": "Le meilleur \ud83d\udc8e", "created_time": "1490310953", "from": {"id": "3087752505", "full_name": "MONSIEUR_AIR", "profile_picture": "https://scontent-lht6-1.cdninstagram.com/t51.2885-19/s150x150/12445903_1525336111106108_2022178690_a.jpg", "username": "monsieur_air"}}], "count": 3}, "can_view_comments": true, "can_delete_comments": false, "type": "image", "link": "https://www.instagram.com/p/BNzvpsoAa0x/", "location": null, "alt_media_url": null}], "more_available": false, "status": "ok"}

我想提取用户ID,所以我尝试了以下

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script>
  var settings = {

    "url": "https://www.instagram.com/35mmslrs/media/",
    "method": "GET",
    "dataType": "json",
    "headers": {}
  }

  $.ajax(settings).done(function (data) {
    console.log(data);
    if(data){  //response is not null or undefined
        $("#instaid").append('<li>' + data.items.user.id + '</li>');
    }else{
       alert('Empty response');
     }


  });
</script>

<h2>Instagram ID/h2>
<ul id="instaid"></ul>

但我似乎无法让它发挥作用?

1 个答案:

答案 0 :(得分:0)

您没有迭代您正在接收的对象数组的根目录,请尝试使用$.each,这次迭代您获得的数据元素中的每个item

<script>
  ...
  $.ajax(settings).done(function (data) {
    if (data) {
      $.each(data.items, function(index, value){
        $("#instaid").append('<li>' + value.user.id + '</li>');
      });
    } else{
      alert('Empty response');
    }
  });
</script>

一个例子:

&#13;
&#13;
let items = {"items":[{"id":"1475526779741400854_4248709454","code":"BR6H8nbD-8W","user":{"id":"4248709454","full_name":"35mmslr","profile_picture":"https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg","username":"35mmslrs"}},{"id":"1401726211293696218_4248709454","code":"BNz7pAAg9Da","user":{"id":"4248709454","full_name":"35mmslr","profile_picture":"https://scontent-lht6-1.cdninstagram.com/t51.2885-19/15251788_170741276731892_4757080909188956160_a.jpg","username":"35mmslrs"}}]}

$.each(items.items, function(index, value){
  $("#instaid").append('<li>' + value.user.id + '</li>');
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<h2>Instagram ID</h2>
<ul id="instaid"></ul>
&#13;
&#13;
&#13;