发布到 Facebook 时如何避免发布重复内容?

发布于 2024-12-26 01:23:12 字数 445 浏览 4 评论 0原文

使用 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 技术交流群。

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

发布评论

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

评论(1

那小子欠揍 2025-01-02 01:23:12

我从 Facebook 收到成功或错误结果。

嗯。当我发布到 Graph API 时,我收到错误或帖子的 ID。我从来没有看到任何成功消息。您在 API 周围使用什么 SDK?

偶尔,API 需要很长的时间和连接时间
出来。

通常,当事情运行缓慢时,这是由于未指定 channelUrl 造成的。请参阅https://developers.facebook.com/docs/reference/javascript/

频道文件的缓存时间很重要
可能的。提供此文件时,您必须发送有效的 Expires 标头
保质期长。这将确保通道文件
由浏览器缓存,这对于流畅的用户体验非常重要。
如果没有适当的缓存,跨域通信将变得非常困难
速度很慢,用户的体验会严重下降。

I get back a success or an error result from Facebook.

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?

Once in a while, the API takes a long time and the connection times
out.

Usually when things are running slowly, it's due to the channelUrl not being specified. See https://developers.facebook.com/docs/reference/javascript/

It is important for the channel file to be cached for as long as
possible. When serving this file, you must send valid Expires headers
with a long expiration period. This will ensure the channel file is
cached by the browser which is important for a smooth user experience.
Without proper caching, cross domain communication will become very
slow and users will suffer a severely degraded experience.

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