首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ACAccountStore -试图在Twitter上跟踪- 410错误

ACAccountStore -试图在Twitter上跟踪- 410错误
EN

Stack Overflow用户
提问于 2013-09-06 18:44:59
回答 1查看 324关注 0票数 0

下面是我的代码“在推特上跟随”(iOS6+):

代码语言:javascript
复制
-(IBAction)twitterFollow
{
    ACAccountStore *accountStore = [[ACAccountStore alloc] init];

    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
        if(granted) {
            // Get the list of Twitter accounts.
            NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];

            NSLog(@"twitter accounts: %@", accountsArray);

            if ([accountsArray count] > 0) {
                // Grab the initial Twitter account to tweet from.
                ACAccount *twitterAccount = [accountsArray objectAtIndex:0];

                NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
                [tempDict setValue:@"myapp" forKey:@"screen_name"];
                [tempDict setValue:@"true" forKey:@"follow"];

                //requestForServiceType

                SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1/friendships/create.json"] parameters:tempDict];
                [postRequest setAccount:twitterAccount];
                [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                    NSString *output = [NSString stringWithFormat:@"HTTP response status: %i Error %d", [urlResponse statusCode],error.code];
                    NSLog(@"%@error %@", output,error.description);

                    NSString *twitterErrorMessage = [error localizedDescription];

                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:kDefaultErrorText message:twitterErrorMessage delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [alert performSelectorOnMainThread:@selector(show)
                                            withObject:nil
                                         waitUntilDone:NO];
                }];
            }else{
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:kDefaultErrorText message:kTextMessageNoTwitter delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
                [alert performSelectorOnMainThread:@selector(show)
                                        withObject:nil
                                     waitUntilDone:NO];
            }

        }
    }];
}

我得到的是:

代码语言:javascript
复制
HTTP response status: 410 Error 0error (null)

我做错了什么?

屏幕名称和帐户是有效的:

代码语言:javascript
复制
twitter accounts: (
    "type:com.apple.twitter\nidentifier: 2ABCDEC6-9D6B-1234-9AB7-847EB167B123\naccountDescription: @theuser\nusername: theuser\nobjectID: x-coredata://ABD5C87A-FB5D-464E-AF18-2C1123451123/Account/p13\nenabledDataclasses: {(\n)}\nenableAndSyncableDataclasses: {(\n)}\nproperties: {\n    fullName = theuser;\n    \"user_id\" = 147712345;\n}\nparentAccount: (null)\nowningBundleID:(null)"
)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-06 22:27:04

好吧,我通过使用1.1API消除了410错误:

代码语言:javascript
复制
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/friendships/create.json"] parameters:tempDict];

现在我得到了一个400错误:

代码语言:javascript
复制
HTTP response status: 400 Error 0error (null)

这表明了无效的身份验证,尽管上面的代码与我在每个教程/示例中看到的代码完全一样。我想我会提出另一个问题..。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18664519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档