使用图形 API 向朋友的墙发布迷你 Facebook 帖子
您好,我已阅读与此相关的所有其他帖子,但我认为我错过了一些基本的东西。我在 ruby on Rails 应用程序中使用 mini_fb 来处理 facebook api。我有以下代码:
current_user.session.post('me', :type => :feed, :params => {:name => "name",
:to => "{\"data\":[{\"name\":\"#{friend.facebook_name}\",\"id\":\"#{friend.facebook_id}\"}]}",
:link => url_of_app,
:description => "desc",
:actions => "{\"name\": \"action name\", \"link\": \"url\"}"})
上面的内容发布到当前用户的留言墙上,无论是否设置“to”参数。除了“to”参数之外,一切正常。我已经一遍又一遍地阅读墙上的图表帖子,但我无法弄清楚我的这段代码有什么问题。如果有人能指出我的错误,我将非常感激。
Hi I have read all the other post relating to this but I think I am missing something fundamental. I am using mini_fb in my ruby on rails application for handling the facebook api. I have the following code:
current_user.session.post('me', :type => :feed, :params => {:name => "name",
:to => "{\"data\":[{\"name\":\"#{friend.facebook_name}\",\"id\":\"#{friend.facebook_id}\"}]}",
:link => url_of_app,
:description => "desc",
:actions => "{\"name\": \"action name\", \"link\": \"url\"}"})
The above posts to the current user's wall with or without the "to" parameter set. Everything works, except for the "to" parameter. I have read the graph post to wall over and over again and I can't figure out what is wrong with this code of mine. I would really appreciate it if someone could point out my mistake.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我从未使用过 ruby 的版本,但问题可能出在第一个参数上。您正在定位“我”的 feed,而应该定位您的朋友的 feed。尝试获取你的朋友 ID 并执行类似的操作
I've never used ruby's version, but probably the problem is in the first parameter. You are targeting 'me' feed, while should be targeting your friends feed. Try fetching your friend id and doing something like
哇,mini_fb 看起来很冗长:)
Telémako 是对的,你需要使用你的朋友 ID。我为您提供了另一种更好的代码替代方案。使用考拉。
https://github.com/arsduo/koala/wiki/Graph-API
我在我的项目中使用它并且效果很好。
Wow, mini_fb looks so verbose :)
Telémako is right, you need to use your friends id. I give you another alternative for more nice code. Use Koala.
https://github.com/arsduo/koala/wiki/Graph-API
I use it in my projects and works very well.