我正试图通过auth找到一个脸书头像。我正在做的事情是:
def image_uri
require 'net/http'
image = URI.parse(params[:image]) # https://graph.facebook.com/565515262/picture
fetch = Net::HTTP.get_response(image)
based = 'data:image/jpg;base64,' << Base64.encode64(fetch)
render :text => based
end我得到以下错误(新的错误编辑):
Connection reset by peer我在谷歌上搜索过,我似乎找不到解决办法,有什么想法吗?
我基本上是在寻找file_get_contents()的的确切功能
发布于 2012-08-23 15:08:26
在解析之前尝试转义URI:
URI.parse URI.escape(params[:image])
确保params[:image]包含要解析的uri .相反,我将传递userid并将其插入uri中。
URI.parse URI.escape("https://graph.facebook.com/#{params[:image]}/picture)"
发布于 2012-08-23 15:13:11
假设你在红宝石上< 1.9.3,你也必须
require 'net/https'如果你在红宝石1.9.3,你不需要做任何事情。
编辑
如果您使用的是最新版本,则只需执行以下操作:
open(params[:image]) # http://graph.facebook.com/#{@user.facebook_id}/picturehttps://stackoverflow.com/questions/12094577
复制相似问题