سؤال

I'm using Twitter.framework to post images to Twitter. I use this code

       // Create an account store object.
        ACAccountStore *accountStore = [[ACAccountStore alloc] init];

        // Create an account type that ensures Twitter accounts are retrieved.
        ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

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


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



                    UIImage *image =[UIImage imageNamed:@"logo"];


                    TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"] 
                                                                 parameters:[NSDictionary dictionaryWithObject:@"Hello. This is a tweet." forKey:@"status"] requestMethod:TWRequestMethodPOST];

                    // "http://api.twitter.com/1/statuses/update.json" 

                    [postRequest addMultiPartData:UIImagePNGRepresentation(image) withName:@"media" type:@"multipart/png"];


                    // Set the account used to post the tweet.
                    [postRequest setAccount:twitterAccount];

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

In logs I see "HTTP response status: 200". It means Success! from twitter site. But I don't understand, how it can be success if I even don't enter any login and password. And where should I set login and password?

هل كانت مفيدة؟

المحلول

You authenticate in the Settings app. I assume it uses xAuth so there is no need for your app to know about the username and password.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top