Пытаясь «подписаться» на кого-то в Twitter с помощью нового API iOS 5, вы получаете ошибку возврата 406. Почему?

Пытаясь «подписаться» на кого-то в Twitter с помощью нового API iOS 5, вы получаете ошибку возврата 406. Почему?

Является ли мой код правильным? Нужно выяснить, почему это не работает....

    - (void)followOnTwitter:(id)sender
{
    ACAccountStore *accountStore = [[ACAccountStore alloc] init];

ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

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

        // For the sake of brevity, we'll assume there is only one Twitter account present.
        // You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present.
        if ([accountsArray count] > 0) {
            // Grab the initial Twitter account to tweet from.
            ACAccount *twitterAccount = [accountsArray objectAtIndex:0];

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

            TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitter.com/1/friendships/create.format"] 
                                                         parameters:tempDict 
                                                      requestMethod:TWRequestMethodPOST];


            [postRequest setAccount:twitterAccount];

            [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
                NSLog(@"%@", output);

                }];
            }
        }
    }];
}

Весь код выглядит корректно. Являются ли параметры неправильными? Правильный ли URL-адрес? Нужно какое-то направление здесь....

28
задан Ethan Allen 10 November 2011 в 20:24
поделиться