tbeseda
1/11/2012 - 2:21 AM

With an access token from Instagram, you can chain a couple JSONP calls together to get a user's recent photos with only their username.

With an access token from Instagram, you can chain a couple JSONP calls together to get a user's recent photos with only their username.

handle = 'yourusername'
api = 'https://api.instagram.com/v1'
token = 'access_token=XxxxXxxxXxxxxX'

$.getJSON "#{api}/users/search?q=#{handle}&#{token}&callback=?", (response) ->
  instagram_user = false
  
  for user in response.data
    if user.username is handle
      instagram_user = user
  
  if user
    $.getJSON "#{api}/users/#{instagram_user.id}/media/recent/?#{token}&callback=?", (response) ->
      images = response.data
      console.log images