Sha256: 799ace8c9bbe6ccd3ca67100e32807464b9423c66ecb45a0018fdfb3e99444df

Contents?: true

Size: 919 Bytes

Versions: 2

Compression:

Stored size: 919 Bytes

Contents

require 'contacts'

begin
  require 'flickr_fu'
rescue LoadError => error
  puts "~> contacts/flickr: Could not load flickr_fu gem."
  puts "~> contacts/flickr: Install it with `gem install flickr_fu'."
  exit -1
end

module Contacts
  
  class Flickr

    attr_accessor :token

    def initialize(config_file)
      confs = YAML.load_file(config_file)['flickr']
      @appid= confs['appid']
      @secret= confs['secret']
    end    

    def get_authentication_url
      ::Flickr.new({:key => @appid, :secret => @secret}).auth.url
    end

    def contacts(frob= nil)
      @token ||= get_token(frob) unless frob.nil?
      ::Flickr.new({:key => @appid, :secret => @secret, :token => @token.token}).contacts.get_list
    end

    # returns a Flickr::Token
    def get_token(frob)
      client= ::Flickr.new({:key => @appid, :secret => @secret})
      client.auth.frob= frob
      client.auth.token
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aurelian-contacts-0.3.1 lib/contacts/flickr.rb
aurelian-contacts-0.3.2 lib/contacts/flickr.rb