Facebook 发帖帮助,每当用户创建帖子时都会添加到 Facebook

发布于 2024-10-28 17:44:56 字数 598 浏览 0 评论 0原文

我认为这个问题是编写漂亮的 ruby​​ 代码的问题,让我看看你们的想法。我已经使用omniauth和fbgraph设置了所有身份验证/访问令牌内容,我似乎无法弄清楚如何在用户创建帖子时集成它。

我的应用程序围绕用户发布帖子(由“标题”和“内容”组成),我希望该帖子能够在 Facebook 或 Twitter 或两者上自动共享,具体取决于用户设置的特定身份验证。如果用户按照常规方式在没有 facebook/twitter 的情况下注册,则不会在任何地方共享。

我如何集成一种动态方式来在用户自动发帖时共享其帖子的标题和内容?我正在考虑某种类型的 after_save 到后期模型,但我无法让它正常工作。感谢您的任何帮助,非常感谢。如果我想稍后分享链接和图片,如果这是一种允许未来扩展的方法,那就太好了。

这是搜索过程中唯一一篇揭示了如何分享给两者的帖子,但我仍然很困惑:( 简单的方法在 Facebook 页面(不是个人资料而是粉丝专页)上发帖的次数

I think this question is a matter of writing nice ruby code, let me see what you guys think. I've already setup all the auth/access token stuff with omniauth and and fbgraph, what I can't seem to work out is how to integrate it when a user creates a post.

My app revolves around users making posts (made up of 'title' and 'content'), I'd like the post to be automatically shared on facebook or twitter or both, depending on the particular authentications the users has setup. And not share anywhere if the user has signed up conventionally without facebook/twitter.

How would I integrate a dynamic way to share the title and content of a user's post whenever they post automatically? I was thinking of some type of after_save to the post model but I can't get it working right. Thank you for any help is it very much appreciated.Also it would great if it was a method that allowed for furture expansion if I wanted to share links and pictures later on.

This is the only post while searching that sheds some light about sharing to both but I'm still confused :(
Easy way of posting on Facebook page (not a profile but a fanpage)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青萝楚歌 2024-11-04 17:44:56

在您的 Post 模型中具有:

after_commit :share_content

def share_content
  user.share_content title, content
end

然后在 User 模型中具有:

def share_content title, content
  # some conditionals with whatever stuff you have to determine whether
  # it's a twitter and/or facebook update...

  if go_for_twitter
    twitter.update title
  end

  if go_for_facebook
    facebook.feed! :message => title
    # ...etc.
  end
end

In your Post model have:

after_commit :share_content

def share_content
  user.share_content title, content
end

Then in User model have:

def share_content title, content
  # some conditionals with whatever stuff you have to determine whether
  # it's a twitter and/or facebook update...

  if go_for_twitter
    twitter.update title
  end

  if go_for_facebook
    facebook.feed! :message => title
    # ...etc.
  end
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文