简体   繁体   中英

How to do login in Twitter using STTwitter for OSX?

Hello,

I am developing a Twitter client for OSX using STTwitter library. I use this code to do login:



    - (void) loginWithUser:(NSString*) user
                  password:(NSString*) password {
        twitter = [STTwitterAPI twitterAPIWithOAuthConsumerKey:kOAuthConsumerKey
                                                consumerSecret:kOAuthConsumerSecret
                                                      username:user
                                                      password:password];

        [twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
            _status = [NSString stringWithFormat:@"Access granted for %@", username];
            _isConnected = YES;
        } errorBlock:^(NSError *error) {
            _isConnected = NO;
            _status = [error localizedDescription];
            NSLog(@"Status: %@",_status);
        }];
    }

I can read direct messages using my personal Twitter account and other development Twitter account but if I try to use other Twitter account from my beta testers I can not read the direct messages.

The error message is:

This application is not allowed to access or delete your direct messages.

I tried to use an OSX system account to do login using this code:



    - (void) loginWithSystemAccount {
        twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];
        [twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
            _status = [NSString stringWithFormat:@"Access granted for %@", username];
            _isConnected = YES;
        } errorBlock:^(NSError *error) {
            _isConnected = NO;
            _status = [error localizedDescription];
            NSLog(@"Status: %@",_status);
        }];
    }

But I can read direct messages using a system account.

I checked the OSX Demo in STTwitter git repository but I could not find a solution. How can I do a right login in Twitter for all users to read direct messages?

Thanks in advance

At first, you should find out if it's a weird behaviour of Twitter API, or a bug in STTwitter.

To do so, I suggest that you try reading direct messages with twurl .

If you're not sure which endpoints you're calling, enable STTwitter networks logs with the STHTTPRequestShowCurlDescription argument.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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