Class: Instagram::Client

Inherits:
API
  • Object
show all
Includes:
Comments, Likes, Locations, Media, Subscriptions, Tags, Users
Defined in:
lib/instagram/client.rb,
lib/instagram/client/tags.rb,
lib/instagram/client/likes.rb,
lib/instagram/client/media.rb,
lib/instagram/client/users.rb,
lib/instagram/client/utils.rb,
lib/instagram/client/comments.rb,
lib/instagram/client/locations.rb,
lib/instagram/client/real_time.rb,
lib/instagram/client/subscriptions.rb

Overview

Note:

All methods have been separated into modules and follow the same grouping used in the Instagram API Documentation.

Wrapper for the Instagram REST API

See Also:

  • TODO:doc_url

Defined Under Namespace

Modules: Comments, Likes, Locations, Media, RealTime, Subscriptions, Tags, Users

Instance Method Summary collapse

Methods included from Subscriptions

#create_subscription, #delete_subscription, #process_subscription, #subscriptions

Methods included from Likes

#like_media, #media_likes, #unlike_media

Methods included from Comments

#create_media_comment, #delete_media_comment, #media_comments

Methods included from Tags

#tag, #tag_recent_media, #tag_search

Methods included from Locations

#location, #location_recent_media, #location_search

Methods included from Media

#media_item, #media_popular, #media_search

Methods included from Users

#user, #user_follows, #user_search

Methods included from OAuth

#authorize_url, #get_access_token

Methods included from Request

#delete, #get, #post, #put

Instance Method Details

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

Returns a list of users whom a given user is followed by

Overloads:

  • #user_followed_by(id = nil, options = {}) ⇒ Hashie::Mash

    Examples:

    Returns a list of users the authenticated user is followed by

    Instagram.user_followed_by

    Parameters:

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

      A customizable set of options.

    Returns:

    • (Hashie::Mash)
  • #user_followed_by(id = nil, options = {}) ⇒ Hashie::Mash

    Examples:

    Return a list of users @mikeyk is followed by

    Instagram.user_followed_by(4) # @mikeyk user ID being 4

    Parameters:

    • user (Integer)

      An Instagram user ID.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: nil

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor attribute to page forward in the list.

    • :count (Integer) — default: nil

      Limits the number of results returned per page, maximum 150.

    Returns:

    • (Hashie::Mash)

See Also:

  • url

Supported formats:

  • :json

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).

Rate Limited:

  • true



91
92
93
94
95
96
# File 'lib/instagram/client/users.rb', line 91

def user_followed_by(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  id = args.first || "self"
  response = get("users/#{id}/followed-by", options)
  response["data"]
end

#user_media_feed(options = {}) ⇒ Array

Returns the 20 most recent media items from the currently authorized user's feed.

Examples:

Return the 20 most recent media images that would appear on @shayne's feed

Instagram.user_media_feed() # assuming @shayne is the authorized user

Parameters:

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

    A customizable set of options.

Options Hash (options):

  • :max_id (Integer)

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

  • :count (Integer)

    Specifies the number of records to retrieve, per page. Must be less than or equal to 100.

Returns:

  • (Array)

See Also:

  • URL

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true



131
132
133
134
135
# File 'lib/instagram/client/users.rb', line 131

def user_media_feed(*args)
  options = args.first.is_a?(Hash) ? args.pop : {}
  response = get('users/self/feed', options)
  response["data"]
end

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

Returns a list of recent media items for a given user

Overloads:

  • #user_recent_media(id = nil, options = {}) ⇒ Hashie::Mash

    Examples:

    Returns a list of recent media items for the currently authenticated user

    Instagram.user_recent_media

    Parameters:

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

      A customizable set of options.

    Returns:

    • (Hashie::Mash)
  • #user_recent_media(id = nil, options = {}) ⇒ Hashie::Mash

    Examples:

    Return a list of media items taken by @mikeyk

    Instagram.user_recent_media(4) # @mikeyk user ID being 4

    Parameters:

    • user (Integer)

      An Instagram user ID.

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

      A customizable set of options.

    Options Hash (options):

    • :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, maximum 150.

    Returns:

    • (Hashie::Mash)

See Also:

  • url

Supported formats:

  • :json

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).

Rate Limited:

  • true



158
159
160
161
162
163
# File 'lib/instagram/client/users.rb', line 158

def user_recent_media(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  id = args.first || "self"
  response = get("users/#{id}/media/recent", options)
  response["data"]
end

#user_requested_byHashie::Mash #user_requested_byHashie::Mash

Returns a list of users whom a given user is followed by

Overloads:

  • #user_requested_byHashie::Mash

    Examples:

    Returns a list of users awaiting approval of a ollow request, for the authenticated user

    Instagram.user_requested_by

    Parameters:

    • options (Hash)

      A customizable set of options.

    Returns:

    • (Hashie::Mash)
  • #user_requested_byHashie::Mash

    Examples:

    Return a list of users who have requested to follow the authenticated user

    Instagram.user_requested_by()

    Returns:

    • (Hashie::Mash)

See Also:

  • url

Supported formats:

  • :json

Requires Authentication:

  • truei

Rate Limited:

  • true



113
114
115
116
# File 'lib/instagram/client/users.rb', line 113

def user_requested_by()
  response = get("users/self/requested-by")
  response["data"]
end