Instagram API and importing photos without server side authentication

丶灬走出姿态 提交于 2019-11-29 19:34:21

问题


I am a bit confused on a certain functionality I would like to implement into a website using the Instagram API. I would like to access my own feed based on my user ID from the Instagram API and display them on my site. It is saying that there is a way to do client side OAuth authentication but I am a bit confused on how I would go about this. I am fairly okay with JavaScript and if someone could point me in the right direction I am sure I could figure it out.

Any best practices would be great.

Thank you in advance,

JN


回答1:


You're asking how to use Client-Side (Implicit) Authentication for Instagram.

Here are a couple JS libraries made for it:

  1. https://github.com/Instagram/instagram-javascript-sdk
  2. https://github.com/potomak/jquery-instagram



回答2:


This was bugging me for ages, but I think I came up with to a simple way to just get my own photo's on my website, using ideas from the "jquery-instagram" plugin, but stripping it way down.

  1. Come up with a #tag and add it to all the photos you want to show on your site, make sure it's not something that just anyone will use. (Do it this way to prevent needing to authenticate anything).

  2. Register your app here: http://instagr.am/developer/register/ (Just use your Instagram login)

  3. Use the following code (with jQuery), where "tag" is the tag you used, "id" is your registered app client id, and "photoCount" is the max number of photos you wish to retrieve.

    $.ajax({
      type: "GET",
      dataType: "jsonp",
      cache: false,
      url: "https://api.instagram.com/v1/tags/" + tag + "/media/recent?client_id=" + id,
      success: function(response) {
        var length = response.data != 'undefined' ? response.data.length : 0;
        var limit = photoCount != null && photoCount < length ? photoCount : length;
        if(limit > 0) {
          for(var i = 0; i < limit; i++) {
            $('<img>', {
              src: response.data[i].images.standard_resolution.url
            }).appendTo($("#photos"));
          }
        }
      }
    });
    


来源:https://stackoverflow.com/questions/7396760/instagram-api-and-importing-photos-without-server-side-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!