Ios 在iPhone中使用社交框架和帐户框架检索Twitter OAuth令牌?

Ios 在iPhone中使用社交框架和帐户框架检索Twitter OAuth令牌?,ios,iphone,ipad,Ios,Iphone,Ipad,我有一个应用程序,我正在做twitter登录,以访问用户的基本信息。我正在使用社会和帐户框架。所有工作正常 `if([self userHasAccessToTwitter]) { ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIden

我有一个应用程序,我正在做twitter登录,以访问用户的基本信息。我正在使用社会和帐户框架。所有工作正常

`if([self userHasAccessToTwitter])
        {
        ACAccountStore *accountStore = [[ACAccountStore alloc] init];
        ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
        [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error){
            if (granted) {
                NSArray *accounts = [accountStore accountsWithAccountType:accountType];
                // Check if the users has setup at least one Twitter account
                if (accounts.count > 0)
                {
                    ACAccount *twitterAccount = [accounts objectAtIndex:0];
                    // Creating a request to get the info about a user on Twitter
                    SLRequest *twitterInfoRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/users/show.json"] parameters:[NSDictionary dictionaryWithObject:twitterAccount.username forKey:@"screen_name"]];
                    [twitterInfoRequest setAccount:twitterAccount];
                    // Making the request
                    [twitterInfoRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                        dispatch_async(dispatch_get_main_queue(), ^{
                            // Check if we reached the reate limit
                            if ([urlResponse statusCode] == 429) {
                                NSLog(@"Rate limit reached");
                                return;
                            }
                            // Check if there was an error
                            if (error) {
                                NSLog(@"Error: %@", error.localizedDescription);
                                return;
                            }
                            // Check if there is some response data
                            if (responseData) {
                                NSError *error = nil;
                                NSArray *TWData = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error];

                                NSString *profileImageStringURL = [(NSDictionary *)TWData objectForKey:@"profile_image_url"];

                                // Update the interface with the loaded data

                                [self getProfileImageForURLString:profileImageStringURL];
                            }
                        });
                    }];
                }
            }
`
但是,如果他没有在设置中配置任何帐户,我需要像instagram一样使用xAuth登录进行自定义登录。有人能帮我吗,我已经完成了这个过程

但我似乎什么都不清楚,如何使用用户名和密码请求访问auth令牌并让他登录twitter是pbm让我困惑的问题。有人能指导我吗?

查看这篇文章。说明使用设置凭据和通过Web登录