Class: Instagram::Client

Inherits:
API
  • Object
show all
Includes:
Comments, Embedding, Geographies, 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/embedding.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 http://instagram.com/developer/

Wrapper for the Instagram REST API

Defined Under Namespace

Modules: Comments, Embedding, Geographies, Likes, Locations, Media, Subscriptions, Tags, Users

Instance Method Summary collapse

Methods included from Embedding

#oembed

Methods included from Subscriptions

#create_subscription, #delete_subscription, #meet_challenge, #process_subscription, #subscriptions, #validate_update

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, #media_shortcode

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

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

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

def approve_user(id, options={})
  options["action"] = "approve"
  response = post("users/#{id}/relationship", options, signature=true)
  response
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:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

def block_user(id, options={})
  options["action"] = "block"
  response = post("users/#{id}/relationship", options, signature=true)
  response
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:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

def deny_user(id, options={})
  options["action"] = "deny"
  response = post("users/#{id}/relationship", options, signature=true)
  response
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:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

def follow_user(id, options={})
  options["action"] = "follow"
  response = post("users/#{id}/relationship", options, signature=true)
  response
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:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

def unblock_user(id, options={})
  options["action"] = "unblock"
  response = post("users/#{id}/relationship", options, signature=true)
  response
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:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

def unfollow_user(id, options={})
  options["action"] = "unfollow"
  response = post("users/#{id}/relationship", options, signature=true)
  response
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:

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


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

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

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

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

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

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:

  • (Hashie::Mash)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

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:

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


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

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

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

def user_relationship(id, options={})
  response = get("users/#{id}/relationship", options)
  response
end

#user_requested_byHashie::Mash #user_requested_byHashie::Mash

Returns a list of users who have requested the currently authorized user's permission to follow

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:

Supported formats:

  • :json

Requires Authentication:

  • true

Rate Limited:

  • true


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

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