5

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?

Waleed Abdulla
  • 1,873
  • 1
  • 14
  • 20
  • Hello, @Waleed. Did you eventually find answer to your question? – Michael Chernetsov Dec 27 '13 at 01:36
  • 1
    @MichaelChernetsov I haven't. There doesn't seem to be a clean way to do it. One idea I thought of is to read the timeline of the page first to check if the post exists there before posting it. That would work, but it's not the clean solution I was looking for. – Waleed Abdulla Dec 28 '13 at 08:12

1 Answers1

-2

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.

DMCS
  • 31,720
  • 14
  • 71
  • 104
  • No, DMCS. This answer doesn't help. While I appreciate the attempt, your answer is not even close to what I asked and totally missed the point of the question. – Waleed Abdulla Dec 28 '13 at 08:09