简体   繁体   English

STTwitter不返回任何成功或错误的信息

[英]STTwitter Not Returning Anything Neither Success or Error

I am having a very hard time here. 我在这里很难过。 There is one part in my application that STTwitter is successful and there is another part (using the same code) that does not return anything. 我的应用程序中有一部分表示STTwitter成功,而另一部分(使用相同的代码)则不返回任何内容。

The part that does NOT work: ` 无效的部分:

-(IBAction)followTwitter:(id)sender {

if ([[NSUserDefaults standardUserDefaults] objectForKey:@"twitter_on_file" ] == nil) {

    UIAlertView *allert = [[UIAlertView alloc] initWithTitle:@"Uh oh!" message:@"You have not linked your twitter account quite yet! Head to My Account settins to do so." delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
    [allert show];

} else {
    ACAccountStore *store1 = [[ACAccountStore alloc] init];
    ACAccountType *twitterAccountType = [store1 accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    if ([twitterAccountType accessGranted]) {
        [store1 requestAccessToAccountsWithType:twitterAccountType options:nil completion:^(BOOL granted, NSError *error) {

            arrayOfUsernames = [[NSMutableArray alloc] init];

            iosAccounts = [store1 accountsWithAccountType:twitterAccountType];
            for (ACAccount *accou in iosAccounts) {
                [arrayOfUsernames addObject:accou.username];
            }

            NSString *usernameOnFile =  [[NSUserDefaults standardUserDefaults] objectForKey:@"twitter_on_file" ];
            int tracker = 0;

            for (NSString *username in arrayOfUsernames) {

                if ([username isEqualToString:usernameOnFile]) {
                    NSLog(@"Using twitter account: %@", username);
                    STTwitterAPI *twitterAPI = [STTwitterAPI twitterAPIOSWithAccount:iosAccounts[tracker]];
                    [twitterAPI verifyCredentialsWithSuccessBlock:^(NSString *username) {
                        NSLog(@"Successfully authenticated the user");

                    } errorBlock:^(NSError *error) {

                        NSLog(@"Erorr: %@", error);

                    }];
                    NSLog(@"Twitter API: %@", twitterAPI);

                    [twitterAPI postFriendshipsCreateForScreenName:@"kickscaterer" orUserID:nil successBlock:^(NSDictionary *befriendedUser) {

                        NSLog(@"Befriend %@", befriendedUser);


                    } errorBlock:^(NSError *error) {

                        NSLog(@"Error: %@", error);
                    }];
                } else {
                    tracker++;
                }
            }
        }];
    }
}

} ` }`

The part that DOES work: 起作用的部分:

  STTwitterAPI *twitter= [STTwitterAPI twitterAPIOSWithAccount:iosAccounts[indexForAlert.row]];

        [twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
            // ...
            NSLog(@"Username: %@", username);
            //  [self.tableView reloadData];


            [[NSUserDefaults standardUserDefaults] setObject:twitter.userName forKey:@"twitter_on_file"];

        } errorBlock:^(NSError *error) {
            NSLog(@"Error: %@", error);
            // ...
        }];

        [twitter postFriendshipsCreateForScreenName:@"didi4" orUserID:nil successBlock:^(NSDictionary *befriendedUser) {

            NSLog(@"Befriend %@", befriendedUser);


        } errorBlock:^(NSError *error) {

            NSLog(@"Error: %@", error);
        }];

Thanks! 谢谢!

应该在成功块调用postFriendshipsCreateForScreenName:方法,该方法的级别应与日志“成功验证用户”的级别相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM