Class: Net::Flickr::Photos

Inherits:
Object
  • Object
show all
Defined in:
lib/net/flickr/photos.rb

Overview

Provides methods for retrieving and/or manipulating one or more Flickr photos.

Don’t instantiate this class yourself. Instead, create an instance of the Flickr class and then use Flickr.photos to access this class, like so:

require 'net/flickr'

flickr = Net::Flickr.new('524266cbd9d3c2xa2679fee8b337fip2')

flickr.photos.recent.each do |photo|
  puts photo.title
end

Instance Method Summary collapse

Constructor Details

#initialize(flickr) ⇒ Photos

Returns a new instance of Photos.



48
49
50
# File 'lib/net/flickr/photos.rb', line 48

def initialize(flickr)
  @flickr = flickr
end

Instance Method Details

#contacts(args = {}) ⇒ Object

Gets a list of recent photos from the calling user’s contacts. This method requires authentication with read permission.

See flickr.com/services/api/flickr.photos.getContactsPhotos.html for details.



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/net/flickr/photos.rb', line 57

def contacts(args = {})
  response = @flickr.request('flickr.photos.getContactsPhotos', args)
  
  photos = []
  
  response.search('photos/photo').each do |photo_xml|
    photos << Photo.new(@flickr, photo_xml)
  end
  
  return photos
end

#contacts_public(user_id, args = {}) ⇒ Object

Gets a list of recent public photos from the specified user’s contacts.

See flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html for details.



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/net/flickr/photos.rb', line 73

def contacts_public(user_id, args = {})
  args[:user_id] = user_id
  
  response = @flickr.request('flickr.photos.getContactsPublicPhotos', args)
  
  photos = []
  
  response.search('photos/photo').each do |photo_xml|
    photos << Photo.new(@flickr, photo_xml)
  end
  
  return photos
end

#counts(args = {}) ⇒ Object

Gets a list of photo counts for the given date ranges for the calling user. The list of photo counts is returned as an XML chunk. This method requires authentication with read permission.

See flickr.com/services/api/flickr.photos.getCounts.html for details.



93
94
95
96
# File 'lib/net/flickr/photos.rb', line 93

def counts(args = {})
  @flickr.request('flickr.photos.getCounts', args).at('photocounts').
      to_original_html
end

#delete(photo_id) ⇒ Object

Deletes the specified photo from Flickr. This method requires authentication with delete permission.

See flickr.com/services/api/flickr.photos.delete.html for details.



102
103
104
# File 'lib/net/flickr/photos.rb', line 102

def delete(photo_id)
  @flickr.request('flickr.photos.delete', :photo_id => photo_id)
end

#geotagged(args = {}) ⇒ Object

Gets a list of the calling user’s geotagged photos. This method requires authentication with read permission.

See flickr.com/services/api/flickr.photos.getWithGeoData.html for details.



111
112
113
# File 'lib/net/flickr/photos.rb', line 111

def geotagged(args = {})
  PhotoList.new(@flickr, 'flickr.photos.getWithGeoData', args)
end

#not_geotagged(args = {}) ⇒ Object

Gets a list of the calling user’s photos that have not been geotagged. This method requires authentication with read permission.

See flickr.com/services/api/flickr.photos.getWithoutGeoData.html for details.



120
121
122
# File 'lib/net/flickr/photos.rb', line 120

def not_geotagged(args = {})
  PhotoList.new(@flickr, 'flickr.photos.getWithoutGeoData', args)
end

#not_in_set(args = {}) ⇒ Object

Gets a list of the calling user’s photos that are not included in any sets. This method requires authentication with read permission.

See flickr.com/services/api/flickr.photos.getNotInSet.html for details.



129
130
131
# File 'lib/net/flickr/photos.rb', line 129

def not_in_set(args = {})
  PhotoList.new(@flickr, 'flickr.photos.getNotInSet', args)
end

#recent(args = {}) ⇒ Object

Gets a list of the latest public photos uploaded to Flickr.

See flickr.com/services/api/flickr.photos.getRecent.html for details.



137
138
139
# File 'lib/net/flickr/photos.rb', line 137

def recent(args = {})
  PhotoList.new(@flickr, 'flickr.photos.getRecent', args)
end

#recently_updated(min_date, args = {}) ⇒ Object

Gets a list of the calling user’s photos that have been created or modified since the specified min_date. This method requires authentication with read permission.

min_date may be either an instance of Time or an integer representing a Unix timestamp.

See flickr.com/services/api/flickr.photos.recentlyUpdated.html for details.



150
151
152
153
# File 'lib/net/flickr/photos.rb', line 150

def recently_updated(min_date, args = {})
  args[:min_date] = min_date.to_i
  PhotoList.new(@flickr, 'flickr.photos.recentlyUpdated', args)
end

#search(args = {}) ⇒ Object

Gets a list of photos matching the specified criteria. Only photos visible to the calling user will be returned. To return private or semi-private photos, the caller must be authenticated with read permission and have permission to view the photos. Unauthenticated calls will return only public photos.

See flickr.com/services/api/flickr.photos.search.html for details.

Note: Flickr doesn’t allow parameterless searches, so be sure to specify at least one search parameter.



165
166
167
# File 'lib/net/flickr/photos.rb', line 165

def search(args = {})
  PhotoList.new(@flickr, 'flickr.photos.search', args)
end

#untagged(args = {}) ⇒ Object

Gets a list of the calling user’s photos that have no tags. This method requires authentication with read permission.

See flickr.com/services/api/flickr.photos.getUntagged.html for details.



174
175
176
# File 'lib/net/flickr/photos.rb', line 174

def untagged(args = {})
  PhotoList.new(@flickr, 'flickr.photos.getUntagged', args)
end

#user(user_id, args = {}) ⇒ Object

Gets a list of public photos for the specified user_id.

See flickr.com/services/api/flickr.people.getPublicPhotos.html for details.



182
183
184
185
# File 'lib/net/flickr/photos.rb', line 182

def user(user_id, args = {})
  args[:user_id] = user_id
  PhotoList.new(@flickr, 'flickr.people.getPublicPhotos', args)
end