Sha256: a4edf240ec3f0077a71926bd2e8b29f187b07e3dc2a9e77c5b0442901647572a

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

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?
      client.contacts.get_list
    end

    # authenticated Flickr client. expects a Flickr::Token
    def client
      @client ||= ::Flickr.new({:key => @appid, :secret => @secret, :token => @token.token})
    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

1 entries across 1 versions & 1 rubygems

Version Path
aurelian-contacts-0.3.3 lib/contacts/flickr.rb