开发者

What is Twitter's duplicate tweet error code?

In my iphone app i am using Twitter-OAuth-iPhone to post and retrieve data from Twitter. The problem is that when someone wants to post a tweet twice(maybe by mistake) i need to tell him that the tweet was already posted.

when i do this i receive a 403 error from Twitter:

request failed with error Error Domain=HTTP Code=403 "The operation couldn’t be completed. (HTTP error 403.)"

the message doesn't tell me that i tried to post a duplicate Tweet. The 403 code, as specified here, 开发者_Python百科is used when requests are being denied due to update limits.

A solution that i thought of is to keep in my app a list of tweets that where posted (an archive) that will be checked every time a new tweet is sent. The problem with this solution is that if someone is updating his twitter status from the web or other app it will fail because the archive from my app will not be updated.

I found a comment that says that the 403 code is just for duplicate tweets, but the documentation says otherwise.

EDIT: on https://github.com/mattgemmell/MGTwitterEngine it says that:

In these cases you'll receive a call to requestFailed:withError: which will include an NSError object detailing the error. Twitter usually returns meaningful HTTP error codes (like 404 for 'user not found', etc), and in that case the -domain of the NSError will be "HTTP" and the -code will be the relevant HTTP status code. The userInfo of the NSError will contain a key "body" that may contain the response body and "response" which will contain the NSHTTPURLResponse. This makes it really, really easy to know what's happening with your connections.

but the userInfo attribute of the NSError that i receive in my app is null.


The problem is that Twitter-OAuth-iPhone for 4xx responses does not return the response body. A solution could be to modify the MGTwitterEngine to provide the full error message. An example can be found here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜