Module: Instagram::Client::Users

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

Overview

Defines methods related to users

Instance Method Summary collapse

Instance Method Details

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

Returns extended information of a given user

Returns The requested user.

Examples:

Return extended information for @shayne

Instagram.user(20)

Parameters:

  • user (Integer)

    An Instagram user ID

Returns:

  • (Hashie::Mash)

    The requested user.

See Also:

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



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

def user(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  id = args.first || 'self'
  response = get("users/#{id}", options)
  response
end

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

Returns a list of users whom a given user follows

Overloads:

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

    Examples:

    Returns a list of users the authenticated user follows

    Instagram.user_follows

    Parameters:

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

      A customizable set of options.

    Returns:

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

    Examples:

    Return a list of users @mikeyk follows

    Instagram.user_follows(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.

    Returns:

    • (Hashie::Mash)

See Also:

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



63
64
65
66
67
68
# File 'lib/instagram/client/users.rb', line 63

def user_follows(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  id = args.first || "self"
  response = get("users/#{id}/follows", options)
  response
end

#user_search(query, options = {}) ⇒ Hashie::Mash

Returns users that match the given query

Examples:

Return users that match "Shayne Sweeney"

Instagram.user_search("Shayne Sweeney")

Parameters:

  • query (String)

    The search query to run against user search.

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

    A customizable set of options.

Options Hash (options):

  • :count (Integer)

    The number of users to retrieve.

Returns:

  • (Hashie::Mash)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • false

Rate Limited:

  • true



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

def user_search(query, options={})
  response = get('users/search', options.merge(:q => query))
  response
end