Sha256: b6f1bce19905fa1ac134b14caa617029cdf86ee6062a9da9271a38a556851387

Contents?: true

Size: 514 Bytes

Versions: 2

Compression:

Stored size: 514 Bytes

Contents

require 'open-uri'
require 'nokogiri'

module PictureFrom
  module Apis
    class FacebookApi

      # TODO: Use the http://graph.facebook.com/karreiro/picture?redirect=false
      # API to identify silhouette pictures.
      def image_url_by_username(username)
        url = "http://graph.facebook.com/#{username}/picture"
        open URI.escape(url)
      rescue OpenURI::HTTPError
        # handle 404 and 400
        nil
      rescue RuntimeError
        # handle 302
        url
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picture_from-1.0.1 lib/picture_from/apis/facebook_api.rb
picture_from-1.0.0 lib/picture_from/apis/facebook_api.rb