1

Omniauth バージョン 1.0.2 を使用してenv["omniauth.auth"]["info"]["image"]、現在、現在のユーザーの画像を取得するために呼び出すと、URL を取得します。
http://graph.facebook.com/100002739564577/picture?type=square
これは、必要な実際の jpeg URL にリダイレクトされます。
http://profile.ak.fbcdn.net/hprofile-ak-ash2/532749_100003719364175_332972681_a.jpg

RailsでjpegのURLを直接取得することは可能ですか?

ありがとう

4

1 に答える 1

2

画像を表示したい場合は、必ずしもそうする必要はありません。これは機能します: <img src="http://graph.facebook.com/100002739564577/picture?type=square" />

ただし、必要な場合は、これを試してください。

url = URI.parse('http://graph.facebook.com/100002739564577/picture?type=square')
res = Net::HTTP.get_response(url)
res['location'] #returns the image URL
于 2012-05-14T15:22:17.470 に答える