在iOS7上使用令牌创建的Twitter帐户失败 [英] Twitter account created with tokens fails on iOS7

查看:413
本文介绍了在iOS7上使用令牌创建的Twitter帐户失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款在iOS6 / 7上运行的应用,并在Twitter上发布自定义视图。为了改善用户体验,如果没有可用的系统帐户,我会向用户提供webview以输入他们的凭据,按照ACAccountCredential.h中的建议将其存储在ACAccountStore中并使用它来发布。

I am working on an app running on iOS6/7, with custom views to post on Twitter. To improve user experience, if no system accounts are available, I would present the user with a webview to enter their credentials, store them in the ACAccountStore as suggested in ACAccountCredential.h and use it to post.

它在iOS6上运行良好,但iOS7共享上的失败,错误为401 。奇怪的是,帐户在ACAccountStore中保存没有错误,并且可以被Twitter应用程序用于在Twitter上阅读和发布(没有进一步登录),因此我假设帐户(令牌和令牌密钥)正常工作。

It works great on iOS6 but on iOS7 sharing fails with 401 error. The weird thing is that the account is saved with no errors in the ACAccountStore and can be used by the Twitter app to read and post on Twitter (with no further login), so I assume the account (token and token secret) is working properly.

SLRequest *postRequest = nil;
NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"];
NSDictionary *content = @{@"status":self.textToShare};
postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:url
parameters:content];

[postRequest setAccount:self.twitterAccount];
[postRequest performRequestWithHandler:completionHandler];

我也尝试过使用API​​ v1.1,但它似乎没有帮助。任何想法?

I tried also with API v1.1 but it does not seem to help. Any ideas?

推荐答案

iOS6和iOS7都会出现此问题,因为 / 1 / status /update.json 现已弃用。此外,从API的v1.1开始,您必须对所有请求使用HTTPS。

This problem will occur on iOS6 as well as iOS7, since /1/statuses/update.json is now deprecated. Also, beginning with v1.1 of the API, you must use HTTPS for all requests.

您的网址应更改为以下内容:

Your URL should be changed to the following:

NSURL *url = [NSURL URLWithString:
              @"https://api.twitter.com/1.1/statuses/update.json"];

有关详细信息,请参阅 Twitter API常见问题解答:API v1的退役需要什么?

For more information, please see Twitter API FAQ: What does the retirement of API v1 entail?

这篇关于在iOS7上使用令牌创建的Twitter帐户失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆