Skip to content

Instantly share code, notes, and snippets.

@pootsbook
Last active December 16, 2015 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pootsbook/5488873 to your computer and use it in GitHub Desktop.
Save pootsbook/5488873 to your computer and use it in GitHub Desktop.
Get a Facebook or Twitter Profile Image
require 'koala'
client = Koala::Facebook::API.new(user_access_token)
picture_response = client.get_object('me', fields: "picture.width(200).height(200)")
# { "id"=>"37100599",
# "picture" => {
# "data"=> {
# "url"=>"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c205.44.551.551/s200x200/314850_740167411782_1416727952_n.jpg",
# "width"=>200,
# "height"=>200,
# "is_silhouette"=>false
# }
# }
# }
picture_url = picture_response["picture"]["data"]["url"]
#=> "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c205.44.551.551/s200x200/314850_740167411782_1416727952_n.jpg"
require 'twitter'
# You must be authenticated
picture_url = Twitter.user(twitter_uid).profile_image_url(:bigger)
#=> "http://si0.twimg.com/profile_images/192487090/philip_bigger.jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment