发布照片从Heroku的Facebook的开放图谱,使用回报率,FbGraph宝石和S3 [英] Posting a photo to the Facebook Open Graph from Heroku, using RoR, FbGraph Gem, and S3
问题描述
我想允许用户分享他的Facebook墙上的照片。我用回形针来存储所有我的应用程序的照片在S3上。因此,在下面的例子@ photo.image.url是我要发布的some_album图像的S3网址。使用fb_graph宝石,这是在本地主机上相对容易。在我的控制器我有:
I am trying to allow a user to share a photo on his Facebook wall. I use Paperclip to store all of my app's photos on S3. So in the below example @photo.image.url is the S3 url of an image that I want to post in some_album. Using the fb_graph gem this is relatively easy on localhost. In my controller I have:
the_photo = open(@photo.image.url)
some_album.photo!(
:access_token => access_token,
:source => the_photo
)
在localhost the_photo的类是将它视为档案。
the_photo's class on localhost is "Tempfile".
在Heroku的事情变得棘手。使用相同的code两(貌似相关的)事情发生。首先,the_photo是类类型StringIO的。其次,当FbGraph帖子给Facebook我得到以下错误:
On heroku things get tricky. Using the same code two (seemingly related) things happen. First, the_photo is class type "stringIO". Second when FbGraph posts to Facebook I get the following error:
FbGraph::InvalidRequest (OAuthException :: (#324) Requires upload file):
的事实,也可能帮助下面有几个要点:
Heres a few bullet points of facts that might also help:
- 的Heroku是一个只读的系统,但显然你的可以的写入它视为
- 在我on Rails的3.1.0
- 的Ruby 1.9.2
- 在Heroku的堆栈竹美里
- Heroku is a read only system, but apparently you can write to a Tempfile
- I am on Rails 3.1.0
- Ruby 1.9.2
- Heroku Stack Bamboo-Miri
任何帮助/想法/变通/问题将大大AP preciated。
Any help/thoughts/work arounds/questions would be greatly appreciated.
推荐答案
我不知道为什么这样做的伎俩,但这个工作对我来说:
I am not sure why this did the trick but this worked for me:
some_album.photo!(
:access_token => access_token,
:source => open(@photo.image.url)
)
而不是设置变量photo_response =打开(@ photo.image.url)。
as opposed to setting a variable photo_response = open(@photo.image.url).
这篇关于发布照片从Heroku的Facebook的开放图谱,使用回报率,FbGraph宝石和S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!