Module: Instagram::Client::Locations

Included in:
Instagram::Client
Defined in:
lib/instagram/client/locations.rb

Overview

Defines methods related to media items

Instance Method Summary collapse

Instance Method Details

#location(id) ⇒ Hashie::Mash

Returns extended information of a given Instagram location

Returns The requested location.

Examples:

Return extended information for the Instagram office

Instagram.location(514276)

Parameters:

  • location (Integer)

    An Instagram location ID

Returns:

  • (Hashie::Mash)

    The requested location.

See Also:

Supported formats:

  • :json

Requires Authentication:

  • false

Rate Limited:

  • true



16
17
18
19
# File 'lib/instagram/client/locations.rb', line 16

def location(id, *args)
  response = get("locations/#{id}")
  response
end

#location_recent_media(id, options = {}) ⇒ Hashie::Mash

Returns a list of recent media items for a given Instagram location

Examples:

Return a list of the most recent media items taken at the Instagram office

Instagram.location_recent_media(514276)

Parameters:

  • user (Integer)

    An Instagram location ID.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :max_timestamp (Integer) — default: nil

    Return media before this UNIX timestamp

  • :max_id (Integer) — default: nil

    Returns results with an ID less than (that is, older than) or equal to the specified ID.

  • :count (Integer) — default: nil

    Limits the number of results returned per page.

Returns:

  • (Hashie::Mash)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • false

Rate Limited:

  • true



36
37
38
39
40
# File 'lib/instagram/client/locations.rb', line 36

def location_recent_media(id, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get("locations/#{id}/media/recent", options)
  response
end

#location_search(options = {}) ⇒ Hashie::Mash

Returns Instagram locations within proximity of given lat,lng or foursquare venue id

Returns location resultm object, #data is an Array.

Examples:

1: Return a location with the Foursquare Venue ID = ()

Instagram.location_search("3fd66200f964a520c5f11ee3") (Schiller's Liquor Bar, 131 Rivington St., NY, NY 10002)

2: Return locations around 37.7808851, -122.3948632 (164 S Park, SF, CA USA)

Instagram.location_search("37.7808851", "-122.3948632")

Parameters:

  • foursquare_v2_id (String)

    A valid Foursquare Venue ID (v2)

  • lat (String)

    A given latitude in decimal format

  • lng (String)

    A given longitude in decimal format

Options Hash (options):

  • :count (Integer)

    The number of media items to retrieve.

Returns:

  • (Hashie::Mash)

    location resultm object, #data is an Array.

See Also:

Supported formats:

  • :json

Requires Authentication:

  • false

Rate Limited:

  • true



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/instagram/client/locations.rb', line 58

def location_search(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  case args.size
  when 1
    foursquare_v2_id = args.first
    response = get('locations/search', options.merge(:foursquare_v2_id => foursquare_v2_id))
  when 2
    lat, lng = args
    response = get('locations/search', options.merge(:lat => lat, :lng => lng))
  when 3
    lat, lng, distance = args
    response = get('locations/search', options.merge(:lat => lat, :lng => lng, :distance => distance))
  end
  response
end