如何使用考拉宝石将图像发布到Facebook

时间:2014-02-28 07:00:28

标签: facebook ruby-on-rails-3 web-services koala

我正在使用此代码将图片发布到Facebook

 def post_to_facebook(facebook_auth)
    graph = Koala::Facebook::GraphAPI.new(facebook_auth.token)
       graph.put_wall_post(self.message, {
      "picture" => self.avatar.url(:thumb),
      "description" => self.message
        })
 end

但我无法打开本地图片

没有这样的文件或目录@ rb_sysopen - index5.jpeg

如果有人知道解决方案,请告诉我

1 个答案:

答案 0 :(得分:-1)

def post_to_facebook(facebook_auth,image,content)
      begin
         graph = Koala::Facebook::GraphAPI.new(facebook_auth.token)
         graph.put_picture(image,content,{:message => self.message})
         rescue Faraday::Error::ConnectionFailed => e  
      end  
end