Giter VIP home page Giter VIP logo

jquery-instagram's Introduction

jQuery Instagram

Select and show a list of Instagram photos.

Getting Started

Download the production version or the development version.

In your web page:

<div class="instagram"></div>

<script src="jquery.js"></script>
<script src="dist/instagram.min.js"></script>
<script>
jQuery(function($) {
  $('.instagram').on('willLoadInstagram', function(event, options) {
    console.log(options);
  });
  $('.instagram').on('didLoadInstagram', function(event, response) {
    console.log(response);
  });
  $('.instagram').instagram({
    hash: 'love',
    clientId: 'YOUR-CLIENT-ID-HERE'
  });
});
</script>

CDN

Production version: //cdnjs.cloudflare.com/ajax/libs/jquery-instagram/0.3.1/instagram.min.js

Development version: //cdnjs.cloudflare.com/ajax/libs/jquery-instagram/0.3.1/instagram.js

Note: please don't use RawGit as a CDN, see The naughtiness score for more info about this issue.

For Rails developers

You can use "instagramjs-rails" gem by bodrovis (https://github.com/bodrovis/instagramjs-rails) to easily add Instagram.js to your projects.

Add this line to your application's Gemfile:

gem 'instagramjs-rails'

And then execute:

$ bundle

In your application.js you will need to add this line:

//= require jquery.instagram

Documentation

Authentication

You can obtain a client id registering a new Instagram API client app at http://instagram.com/developer/clients/register/

Options

hash

Get a list of recently tagged media.

See http://instagram.com/developer/endpoints/tags/#get_tags_media_recent

Authentication: clientId required

Type: String

Default: null

userId

Get the most recent media published by a user.

See http://instagram.com/developer/endpoints/users/#get_users_media_recent

Authentication: accessToken required.

Type: Number

Default: null

location

Get a list of recent media objects from a given location.

See http://instagram.com/developer/endpoints/locations/#get_locations_media_recent

Authentication: clientId required.

Type: Object

Default: null

Parameters:

  • id Location id (required).
  • min_timestamp Return media after this UNIX timestamp.
  • max_timestamp Return media before this UNIX timestamp.
  • min_id Return media before this min_id.
  • max_id Return media after this max_id.

search

Search for media in a given area.

See http://instagram.com/developer/endpoints/media/#get_media_search

Authentication: clientId required.

Type: Object

Default: null

Parameters:

  • lat Latitude of the center search coordinate. If used, lng is required.
  • lng Longitude of the center search coordinate. If used, lat is required.
  • min_timestamp A unix timestamp. All media returned will be taken later than this timestamp.
  • max_timestamp A unix timestamp. All media returned will be taken earlier than this timestamp.
  • distance Default is 1km (distance = 1000), max distance is 5km.

accessToken

OAuth 2 access token.

See http://instagram.com/developer/auth/

Type: String

Default: null

clientId

OAuth 2 client application id.

See http://instagram.com/developer/auth/

Type: String

Default: null

count

Number of photos.

See http://instagram.com/developer/endpoints/#pagination

Type: Number

Default: null

Note: Instagram is filtering out private users' photos at read-time, so you won't always get the full number of photos in the count, see also #14 and https://groups.google.com/d/msg/instagram-api-developers/nKik4i8OYhw/ENu79JbcBAEJ

Note: pagination doesn't work for requests to /media/search, see #35.

url

You can populate this with the next URL object (pagination.next_url) returned by the Instagram API.

Type: String

Default: null

Events

willLoadInstagram

Triggered just before making the request to instagram API.

Params:

  • event
  • options

didLoadInstagram

Called after the response from instagram API.

Params:

  • event
  • response

Examples

Get a list of what media is most popular at the moment

See http://instagram.com/developer/endpoints/media/#get_media_popular

$('.instagram').instagram({
  clientId: 'YOUR-CLIENT-ID-HERE'
});

Get a list of recently tagged media

See http://instagram.com/developer/endpoints/tags/#get_tags_media_recent

$('.instagram').instagram({
  hash: 'love',
  clientId: 'YOUR-CLIENT-ID-HERE'
});

Get the most recent media published by a user

See http://instagram.com/developer/endpoints/users/#get_users_media_recent

$('.instagram').instagram({
  userId: 1574083,
  accessToken: 'YOUR-ACCESS-TOKEN-HERE'
});

Note: this API endpoint needs access token authentication.

Get a list of recent media objects from a given location

See http://instagram.com/developer/endpoints/locations/#get_locations_media_recent

$('.instagram').instagram({
  location: {
    id: 514276
  },
  clientId: 'YOUR-CLIENT-ID-HERE'
});

Search for media in a given area

See http://instagram.com/developer/endpoints/media/#get_media_search

$('.instagram').instagram({
  search: {
    lat: 48.858844,
    lng: 2.294351,
    distance: 2000
  },
  clientId: 'YOUR-CLIENT-ID-HERE'
});

Release History

0.3.1

Add options default values, see #52.

0.3.0

Plugin redesing.

jquery-instagram's People

Contributors

adrianartiles avatar edizaziz-dev avatar gavinballard avatar joeybaker avatar potomak avatar tsharju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-instagram's Issues

Request: Display photos from 'userId' tagged 'hash'

These two functions are available independently, any possible way to combine them?

I don't think the Instagram API readily supports this, but perhaps it's possible to fetch all images from a specific user and then filter those images by hashtag?

setting distance parameter when using location

Is it possible to set a distance as outlined here when using locationId? This way you can more or less retrieve photos within a certain distance of a given location. This is already a part of the Instagram API.

Instagram unshown

Hello, This is Ryo, web director from Japan.

I have a question about Instagram plugin.
The website we built have not shown Instagram from yesterday.
could be cause of :https://www.instagram.com/developer/

could you clear this problem??

thank you.

Access token & client id check inconsistent with comment

I am referring to the following part of the code:

if (options.accessToken == null && options.clientId == null) {
  throw 'You must provide an access token or a client id';
}

The error message suggests that you must provide an access token or a client id, however in reality the code itself has the and (&&) logical operator. So, either the error message should read 'You must provide an access token and a client id', or the code should be updated to use the or (||) logical operator.

Which one is correct? I am happy to open a pull request and update this accordingly (obviously following the contribution guidelines).

Can you help me get your code to work again?

I am having trouble understanding how to adapt your code to the new instagram requirement for an access token.

I have logged into my client’s account and created a client ID. I don’t know what to do next, in order to get the required access token. Instagram says in the docs* to "Direct the user to our authorization url” but does not provide the URL! Can you help with this?

Thanks in advance for any help you can provide. I am not an experienced developer but have some javascript and jquery experience. The three pages that use your code are:

http://corduroyshop.com//instagram-feeds/instagram-left.html
http://corduroyshop.com//instagram-feeds/instagram-middle.html
http://corduroyshop.com//instagram-feeds/instagram-right.html

Thanks again.

Antony Gravett

Feed Not displaying all the time....

I'm no programmer at all, solely a graphic designer, but with a little bit of luck and magic I finally pulled off your code to create this site

http://www.halilife.com

I found as soon as my site started to pick up some decent traffic though, the feed only displayed every now and then. I'm using your hashtag version.... does it have to do with how the site is caching elements? again I really have no idea what I'm coin, and I'm learning every step I take. Thanks in Advance, Josh

requests with next_url show only 1 new photo

Hey guys!

Thanks for the plugin... its awesome!

I'm trying to do use next_url parameter just like the alternative method presented in main page. The call will return only one sole image, even if more than that is claimed by show parameter.

I think it's partially an API issue, as data parameter in ajax callback seems to be populated by Instagram servers directly. Even though, I think this plugin could partially rewrite these parameter, as user considers more variables on next requests.

Line 75 seems to be the point to do these things. Currently, it returns the next_object just as it was provided... skipping all other parameters involved. Indeed, this issue has actually a broader scope, as more parameters are considered. show was just the one I've used.

At the end... show 1 is just too little :) After testing my code over and over, I've noticed it was freezing sometimes... as ajax callback delays its arrival (it even stops sometimes). Maybe due to too much requests in an one to one pagination usage.

Well, what about it?

getting "object has no method 'instagram' " error.

i already saw this post: #4
but the solution does not apply in my case.

$(".instagram").instagram({
hash: 'something',
clientId: myClientId
});

I've imported the script and followed all instructions, but still nothing. please help!

Show more than 20 pics

Hello
Thx for your plugin !
I tried your alternative method to show more than 20 photos, but i get this error message :

Uncaught TypeError: Cannot read property 'pagination' of undefined

any idea please ?

thx !

Change default distance using lat/long search?

According to the API specs:

Default is 1000m (distance=1000), max distance is 5000.

Do we have control over it in this script? Would love to reduce it for greater accuracy. I see in line 87:

settings.search.distance != null && (params.distance = settings.search.distance);

no method 'instagram'

I'm getting a no method 'instagram' from following the sample provided in the Readme. Any suggestions?

$(".instagram").instagram({

Using text input to change hash won't change tag in next_url

I'm trying to add the ability to change the hash in a text input (selectedHash) and then have new images with this new tag load when the "more" button is pressed as in your example code. I can see in the console that the hash changes but not the url. Obviously I'm missing something as to getting the tag in the next_url to change. Any help would be appreciated!
Here is my code.

     var selectedHash = $( "input:text[name=hash]" ).val(); 
  var
    insta_container = $(".instagram")
  , insta_next_url

  insta_container.instagram({
       next_url : insta_next_url,
      hash: selectedHash
    , clientId : '4cc3fc9df774483cb575b405f3c1cc21'
    , show : 5
    , onComplete : function (photos, data) {
      insta_next_url = data.pagination.next_url
    }
  })

  $('button').on('click', function(){
      var selectedHash = $( "input:text[name=hash]" ).val();
    var 
      button = $(this)
    , text = button.text()

    if (button.text() != 'Loading…'){
      button.text('Loading…')
      insta_container.instagram({
          next_url : insta_next_url,
          hash: selectedHash
        , show : 5
        , onComplete : function(photos, data) {
          insta_next_url = data.pagination.next_url

          button.text(text);
            console.log( selectedHash )
            console.log( insta_next_url )
        }
      })
    }       
  }) 
});

Images appending twice

Hi, This is probably just a dumb mistake I'm making but I'm having a problem with the

$('.instagram').on('didLoadInstagram', function(event, response)

running twice so my images get appended twice. I know its running twice because I checked it with a print statement. Here is the full function in my code:

$('button').click(function(){
    jQuery(function($) {
      $("#pictures").html("");
      $('.instagram').on('willLoadInstagram', function(event, options) {
        console.log(options);
      });
      $('.instagram').on('didLoadInstagram', function(event, response) {
        console.log(response)
        console.log("go")
        for (i = 0; i < response.data.length; i++) {
            var DOM_img = document.createElement("img");
            var link = document.createElement('a'); 
            DOM_img.setAttribute('src', response.data[i].images.thumbnail.url);
            link.setAttribute('href', response.data[i].link);
            link.appendChild(DOM_img)
            pictures.appendChild(link);
        }

      });
      $('.instagram').instagram({
        search: {
        lat: lat,
        lng: lng,
        distance: document.getElementById('Distance').value
      },
        count : 33,
        clientId: 'removed'
      });
    });
});

Thanks for any help on this

Merging with "Animated Responsive Image Grid"

Hello,

So I have got the point of changing the jquery instagram plugin to publish the photos into a UL list instead of divs. That was fairly straight forward.

Next I installed the "Animated Responsive Image Grid" from this source: http://tympanus.net/codrops/2012/08/02/animated-responsive-image-grid/

In their plugin they take that UL list of images, strip the image from the li and add it as an image background to the a:link that is created. Again this works fine if there is a list of static images... but not when that list is generated by the instagram plugin.

But why? - it is still a list with an image and a src that can be stripped by the responsive image plugin and added to the a:link as a background-image...

My query is this:

How would you guys/gals merge these two plugins so you get al the functions/animations of the responsive grid with a list of images that are being automatically generated by the instagram plugin?

Additional condition: 'user_has_liked'

Hi, I'm not an advanced JS coder, but trying to muddle through...

I'm looking for a way to "approve" the photos that appear in my gallery using this plugin. I thought perhaps I could do this by liking any hashtagged photos as a method of approval.

Is there a way to utilize this plug-in to return photos with both a hashtag AND a true "user_has_liked" key? I am using an oauth access token for the appropriate account, so I believe I have the user_has_liked key at my disposal (according to the Instagram API documentation). I just don't know how to write it into this javascript as a condition.

Thanks!

Events

The plugin should trigger events for:

  • load
  • complete

See also #21

bower

if you put in bower minified version developer in development mode can debug.
there are tool as bindep making all after.

Likes Limits

Hello,

does anyone know why I get a correct likes count for a photo, let's say 11 for example, and then in the following array containing the likes I only have 3 or 4 cells, and not all the 11 likes?

It happens with all the photos I try to retrieve.

Thanks for your help.

Matt

Pull from userId

I have this installed, but I can't get anything when I call for userId.

Here is my call to the function:

<script> $(document).ready(function() { $(".instagram.cid").instagram({ userId: 'my_user_id', show: 5, clientId: clientId }); }); </script>

And my div:

It doesn't populate.

What is the limit for number of images? Is it possible to overcome it or implement infinite scroll?

Hello

It seems that there is a limit where I cannot load more images. I read another issue here where it said that since some instagram-photos are private, it won't always output as many images as specified. But even if I put something like 1000, there seems to be a limit besides that.

Is it possible to make another requst to load more images and this way create infinite scroll type behaviour?

Thank you!

Hide accesstoken and userID

Do you have a suggestion for hiding the accesstoken and userID from being output onto the page when using this? I don't think users would really like that info to be naked in their site code. Do you have examples of this being used publicly. I noticed the demo only uses the clientID which is fine because you can limit your Client by domain, but not so when pulling info from a personal account.

Any suggestions or examples would be appreciated. Thanks for putting this together, great work overall!

GitHub page script loading error

Refused to execute script from 'https://github.com/potomak/jquery-instagram/raw/master/jquery.instagram.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.

Error in console when grabbing feed by lat/lng coordinates

When I implement this plugin using a hash tag to pull a feed with a "more" button it works beautifully. However, when I try to get a feed of images based on latitude and longitude coordinates (again, with a more button) I get this error in the console:

Uncaught TypeError: Cannot read property 'next_url' of undefined

And of course, the more button doesn't work (just throws this error over and over again as you click it, and it's permanently stuck on "Loading...").

Any ideas what might cause this behavior? In both cases I implemented the plugin in exactly the same way, just swapped the hash option for the search: {lat/lng} options. I'm working locally at the moment so I can't provide a link.

Thanks!

Overwriting PhotoLink and other settings

I think there should be the ability to build your own anchor if you'd like and be able to overwrite the settings. So instead of using

settings = {
  // ...
  , photoLink: true
};

You allow for the ability to override or not. Current it just says,

if (settings.photoLink) {
  innerHtml = $('<a>')
    .attr('target', '_blank')
    .attr('href', photo.link)
    .append(innerHtml);
}

which only allows for bool.

And now that I have this script on CDNjs (http://cdnjs.com), vanilla copies may be preferred, rather than custom hacks to source code.

Doesn't load

I am not sure why, but it does not work at all =(
Example code is not working, i see the request to instagram api but nothing is loaded
Also installed bower component, does not helped much. I am not a pro developer, but using the example and legal instagram auth token, client id does not make it happen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.