2011-03-18 37 views
2

在我的iphone應用程序中,我使用Twitter-OAuth-iPhone從Twitter發佈和檢索數據。問題是,當有人想發佈兩條推文(可能是錯誤的)時,我需要告訴他推文已經發布。什麼是Twitter的重複鳴叫錯誤代碼?

當我做到這一點我收到一個403錯誤從Twitter:

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

消息不告訴我,我想張貼重複的Twitter消息,當由於更新限制而拒絕請求時,將使用403代碼(如指定的here)。

,我想到了一個解決方案是在我的應用程序,以保持鳴叫的列表,其中貼(存檔),其將每一個新的鳴叫發送時間檢查。這個解決方案的問題是,如果有人從網絡或其他應用程序更新他的Twitter狀態,它將失敗,因爲我的應用程序中的檔案不會被更新。

我發現了一個comment,指出403代碼只是重複的微博,但文檔,否則說。

編輯:於https://github.com/mattgemmell/MGTwitterEngine 它說:

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.

但我收到我的應用程序的NSError的用戶信息屬性爲null。

+1

見http://stackoverflow.com/questions/4874532/twitter-error-could-not-post-tweet 403被用於重複的微博也與「原因:狀態是重複的。」 – robertvojta 2011-03-18 12:30:36

+1

在我收到「原因:狀態是重複的」的NSError未指定。我剛剛收到 - > Error Domain = HTTP Code = 403「操作無法完成(HTTP錯誤403.)」 – 2011-03-18 12:52:41

回答

2

的問題是,Twitter的OAuth的iPhone爲4xx響應不返回響應主體。 解決方案可能是修改MGTwitterEngine以提供完整的錯誤消息。一個例子可以發現here