Goalie
Goalie

Reputation: 3105

How do you directly access the Omniauth facebook image url?

Using Omniauth version 1.0.2, currently when I call env["omniauth.auth"]["info"]["image"] to get the image for the current user I get a URL:
http://graph.facebook.com/100002739564577/picture?type=square
This redirects to the actual jpeg url which is what I want:
http://profile.ak.fbcdn.net/hprofile-ak-ash2/532749_100003719364175_332972681_a.jpg

Is it possible to get the jpeg url directly in rails?

Thanks

Upvotes: 1

Views: 411

Answers (1)

Peter Wong
Peter Wong

Reputation: 491

You don't necessarily have to if you want to display the image. This works: <img src="http://graph.facebook.com/100002739564577/picture?type=square" />

If you must however, try this:

url = URI.parse('http://graph.facebook.com/100002739564577/picture?type=square')
res = Net::HTTP.get_response(url)
res['location'] #returns the image URL

Upvotes: 2

Related Questions