发布到 Facebook 时如何避免发布重复内容?
使用 Graph API,我通过 POST 到 /me/feed 连接来发布故事。我从 Facebook 收到成功或错误结果。到目前为止,一切都很好。有时,API 需要很长时间并且连接超时。在这种情况下,我不确定请求是否成功或失败(即请求可能从未到达 Facebook,或者可能成功但结果从未返回给我)。你如何处理这种情况?
更多详细信息: 我在Facebook和Twitter上发布了很多帖子,所以超时的情况经常发生。有了 Twitter,解决方案就很简单。如果请求第一次超时,我只需重试。 Twitter 会检测重复项,因此如果第一次成功发布该帖子,那么我在第二次请求时会收到“重复状态”错误,并且我知道我不需要再重试。
但 Facebook 不会检测重复项,因此如果我重试发布请求,我可能会面临将帖子的两份副本发布到用户墙上的风险,这不太好。另一方面,如果我不重试,我就有可能根本无法发布该帖子。想法?
With the Graph API, I publish a story by POSTing to the /me/feed connection. I get back a success or an error result from Facebook. So far so good. Once in a while, the API takes a long time and the connection times out. In that case, I don't know for sure if the request succeeded of failed (i.e. maybe the request never reached Facebook, or maybe it succeeded and the result never made it back to me). How do you handle this situation?
More details:
I publish a lot of posts to Facebook and Twitter, so the timeout situation happens often. With Twitter, the solution is easy. If the request times out the first time, I simply try again. Twitter detects duplicates, so if the post was successfully published the first time, then I'll get a "duplicate status" error on the second request and I know that I don't need to retry any more.
But Facebook doesn't detect duplicates, so if I retry the publish request, I risk having two copies of the post published to the user wall, which is not nice. On the other hand, if I don't retry, I risk having the post not published at all. Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯。当我发布到 Graph API 时,我收到错误或帖子的 ID。我从来没有看到任何成功消息。您在 API 周围使用什么 SDK?
通常,当事情运行缓慢时,这是由于未指定
channelUrl
造成的。请参阅https://developers.facebook.com/docs/reference/javascript/Hmmm. When I post to the Graph API, I get back an error or the id of the post. I never see any success message. What SDK are you using around the API?
Usually when things are running slowly, it's due to the
channelUrl
not being specified. See https://developers.facebook.com/docs/reference/javascript/