gpt4 book ai didi

iphone - Twitter 的重复推文错误代码是什么?

转载 作者:行者123 更新时间:2023-12-03 21:07:52 25 4
gpt4 key购买 nike

在我的 iPhone 应用程序中,我使用 Twitter-OAuth-iPhone 从 Twitter 发布和检索数据。问题是,当有人想发布推文两次(可能是错误的)时,我需要告诉他该推文已经发布了。

当我执行此操作时,我收到来自 Twitter 的 403 错误:

request failed with error ErrorDomain=HTTP Code=403 "The operationcouldn’t be completed. (HTTP error403.)"

这条消息并没有告诉我我试图发布重复的推文。 403 代码,指定 here ,在请求由于更新限制而被拒绝时使用。

我想到的一个解决方案是在我的应用程序中保留发布的推文列表(存档),每次发送新推文时都会检查该列表。此解决方案的问题在于,如果有人从网络或其他应用程序更新他的 Twitter 状态,它将失败,因为我的应用程序中的存档将不会更新。

我找到了comment这表明 403 代码仅适用于重复的推文,但文档另有说明。

编辑:https://github.com/mattgemmell/MGTwitterEngine它说:

In these cases you'll receive a callto requestFailed:withError: which willinclude an NSError object detailingthe error. Twitter usually returnsmeaningful HTTP error codes (like 404for 'user not found', etc), and inthat case the -domain of the NSErrorwill be "HTTP" and the -code will bethe relevant HTTP status code. TheuserInfo of the NSError will contain akey "body" that may contain theresponse body and "response" whichwill contain the NSHTTPURLResponse.This makes it really, really easy toknow what's happening with yourconnections.

但是我在应用程序中收到的 NSError 的 userInfo 属性为 null。

最佳答案

问题是 4xx 响应的 Twitter-OAuth-iPhone 不会返回响应正文。解决方案可能是修改 MGTwitterEngine 以提供完整的错误消息。可以找到一个示例 here .

关于iphone - Twitter 的重复推文错误代码是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5351495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com