Class: Instagram::Client

Inherits:
API
  • Object
show all
Includes:
Comments, Geographies, Likes, Locations, Media, Subscriptions, Tags, Users, Utils
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/geographies.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, Geographies, Likes, Locations, Media, Subscriptions, Tags, Users, Utils

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 Geographies

#geography_recent_media

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 inherited from API

#initialize

Methods included from OAuth

#authorize_url, #get_access_token

Methods included from Request

#delete, #get, #post, #put

Constructor Details

This class inherits a constructor from Instagram::API

Instance Method Details

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

Approve a relationship request between the current user and the target user

Examples:

Approve a relationship request between the current user and the target user

Instagram.approve_user(4)

Parameters:

  • user (Integer)

    An Instagram user ID.

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

    An optional options hash

Returns:

  • (Hashie::Mash)

See Also:



285
286
287
288
289
# File 'lib/instagram/client/users.rb', line 285

def approve_user(id, options={})
  options["action"] = "approve"
  response = post("users/#{id}/relationship", options)
  response["data"]
end

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

Block a relationship between the current user and the target user

Examples:

Block a relationship between the current user and the target user

Instagram.block_user(4)

Parameters:

  • user (Integer)

    An Instagram user ID.

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

    An optional options hash

Returns:

  • (Hashie::Mash)

See Also:



249
250
251
252
253
# File 'lib/instagram/client/users.rb', line 249

def block_user(id, options={})
  options["action"] = "block"
  response = post("users/#{id}/relationship", options)
  response["data"]
end

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

Deny a relationship request between the current user and the target user

Examples:

Deny a relationship request between the current user and the target user

Instagram.deny_user(4)

Parameters:

  • user (Integer)

    An Instagram user ID.

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

    An optional options hash

Returns:

  • (Hashie::Mash)

See Also:



303
304
305
306
307
# File 'lib/instagram/client/users.rb', line 303

def deny_user(id, options={})
  options["action"] = "deny"
  response = post("users/#{id}/relationship", options)
  response["data"]
end

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

Create a follows relationship between the current user and the target user

Examples:

Request the current user to follow the target user

Instagram.follow_user(4)

Parameters:

  • user (Integer)

    An Instagram user ID.

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

    An optional options hash

Returns:

  • (Hashie::Mash)

See Also:



213
214
215
216
217
# File 'lib/instagram/client/users.rb', line 213

def follow_user(id, options={})
  options["action"] = "follow"
  response = post("users/#{id}/relationship", options)
  response["data"]
end

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

Remove a relationship block between the current user and the target user

Examples:

Remove a relationship block between the current user and the target user

Instagram.unblock_user(4)

Parameters:

  • user (Integer)

    An Instagram user ID.

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

    An optional options hash

Returns:

  • (Hashie::Mash)

See Also:



267
268
269
270
271
# File 'lib/instagram/client/users.rb', line 267

def unblock_user(id, options={})
  options["action"] = "unblock"
  response = post("users/#{id}/relationship", options)
  response["data"]
end

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

Destroy a follows relationship between the current user and the target user

Examples:

Remove a follows relationship between the current user and the target user

Instagram.unfollow_user(4)

Parameters:

  • user (Integer)

    An Instagram user ID.

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

    An optional options hash

Returns:

  • (Hashie::Mash)

See Also:



231
232
233
234
235
# File 'lib/instagram/client/users.rb', line 231

def unfollow_user(id, options={})
  options["action"] = "unfollow"
  response = post("users/#{id}/relationship", options)
  response["data"]
end

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

    Returns:

    • (Hashie::Mash)

See Also:

  • url


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_liked_media(options = {}) ⇒ Hashie::Mash

Returns a list of media items liked by the current user

Examples:

Returns a list of media items liked by the currently authenticated user

Instagram.user_liked_media

Parameters:

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

    A customizable set of options.

Options Hash (options):

  • :max_like_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:



179
180
181
182
# File 'lib/instagram/client/users.rb', line 179

def user_liked_media(options={})
  response = get("users/self/media/liked", options)
  response
end

#user_media_feed(options = {}) ⇒ Array

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

Examples:

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

  • :min_id (Integer)

    Return media later than this min_id

  • :count (Integer)

    Specifies the number of records to retrieve, per page.

Returns:

  • (Array)

See Also:



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

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

#user_recent_media(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(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.

    Returns:

    • (Hashie::Mash)

See Also:



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

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_relationship(id, options = {}) ⇒ Hashie::Mash

Returns information about the current user’s relationship (follow/following/etc) to another user

Examples:

Return the relationship status between the currently authenticated user and @mikeyk

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

Parameters:

  • user (Integer)

    An Instagram user ID.

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

    An optional options hash

Returns:

  • (Hashie::Mash)

See Also:



196
197
198
199
# File 'lib/instagram/client/users.rb', line 196

def user_relationship(id, options={})
  response = get("users/#{id}/relationship", 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


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