Module: Instagram::Client::Media

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

Overview

Defines methods related to media items

Instance Method Summary collapse

Instance Method Details

#media_item(id) ⇒ Hashie::Mash

Returns extended information of a given media item

Returns The requested media item.

Examples:

Return extended information for media item 1234

Instagram.media_item(1324)

Parameters:

  • user (Integer)

    An Instagram media item ID

Returns:

  • (Hashie::Mash)

    The requested media item.

See Also:

Rate Limited:

  • true

Requires Authentication:

  • false unless requesting media from a protected user

    If getting this data of a protected user, you must authenticate (and be allowed to see that user).

Supported formats:

  • :json


18
19
20
21
22
# File 'lib/instagram/client/media.rb', line 18

def media_item(*args)
  id = args.first || 'self'
  response = get("media/#{id}")
  response
end

Returns a list of the overall most popular media

Examples:

Returns a list of the overall most popular media

Instagram.media_popular

Parameters:

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

    A customizable set of options.

Returns:

  • (Hashie::Mash)

See Also:

Rate Limited:

  • true

Requires Authentication:

  • false unless requesting it from a protected user

    If getting this data of a protected user, you must authenticate (and be allowed to see that user).

Supported formats:

  • :json


56
57
58
59
60
61
# File 'lib/instagram/client/media.rb', line 56

def media_popular(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  id = args.first || "self"
  response = get("media/popular", options)
  response
end

#media_search(lat, lng, options = {}) ⇒ Hashie::Mash

Returns media items within proximity of given lat,lng

Examples:

Return media around 37.7808851, -122.3948632 (164 S Park, SF, CA USA)

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

Parameters:

  • lat (String)

    A given latitude in decimal format

  • lng (String)

    A given longitude in decimal format

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

    A customizable set of options.

Options Hash (options):

  • :count (Integer)

    The number of media items to retrieve.

Returns:

  • (Hashie::Mash)

    A list of matching media

See Also:

Rate Limited:

  • true

Requires Authentication:

  • false

Supported formats:

  • :json


76
77
78
79
# File 'lib/instagram/client/media.rb', line 76

def media_search(lat, lng, options={})
  response = get('media/search', options.merge(:lat => lat, :lng => lng))
  response
end

#media_shortcode(shortcode) ⇒ Hashie::Mash

Returns extended information of a given media item

Returns The requested media item.

Examples:

Return extended information for media item with shortcode 'D'

Instagram.media_shortcode('D')

Parameters:

  • shortcode (String)

    An Instagram media item shortcode

Returns:

  • (Hashie::Mash)

    The requested media item.

See Also:

Rate Limited:

  • true

Requires Authentication:

  • false unless requesting media from a protected user

    If getting this data of a protected user, you must authenticate (and be allowed to see that user).

Supported formats:

  • none


37
38
39
40
41
# File 'lib/instagram/client/media.rb', line 37

def media_shortcode(*args)
  shortcode = args.first
  response = get("media/shortcode/#{shortcode}", {}, false, false, true)
  response
end