Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram API and importing photos without server side authentication

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

like image 755
jeffreynolte Avatar asked Sep 13 '11 04:09

jeffreynolte


People also ask

How do I upload API photos to Instagram?

Publishing single image, video, story or reel is a two-step process: Use the POST /{ig-user-id}/media endpoint to create a container from an image or video hosted on your public server. Use the POST /{ig-user-id}/media_publish endpoint to publish the container.

What information can you get from Instagram API?

The API can be used to get and publish their media, manage and reply to comments on their media, identify media where they have been @mentioned by other Instagram users, find hashtagged media, and get basic metadata and metrics about other Instagram Businesses and Creators.


2 Answers

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
like image 187
emeth Avatar answered Sep 28 '22 10:09

emeth


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"));
          }
        }
      }
    });
    
like image 37
phenomnomnominal Avatar answered Sep 28 '22 11:09

phenomnomnominal