Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS-使用用户名和密码登录Twitter_Ios_Twitter_Ios7 - Fatal编程技术网

iOS-使用用户名和密码登录Twitter

iOS-使用用户名和密码登录Twitter,ios,twitter,ios7,Ios,Twitter,Ios7,我是iOS开发新手,所以我不清楚该怎么做:使用用户提供的用户名和密码,检查凭据是否是有效的twitter帐户。登录用户并检索用户关注者、帐户信息、时间线和推文 我知道我什么都没试过,但那只是因为我不知道从哪里开始。我在上面搜索了一下,发现了一些关于OAuth的东西。但大部分内容都是针对iOS 5的。看看社交.framework(iOS 6及以上版本)。它管理多个社交网站的身份验证,包括twitter。一旦用户创建了一个帐户并授予您的应用程序访问权限,您就可以使用SLRequest执行经过身份验证

我是iOS开发新手,所以我不清楚该怎么做:使用用户提供的用户名和密码,检查凭据是否是有效的twitter帐户。登录用户并检索用户关注者、帐户信息、时间线和推文


我知道我什么都没试过,但那只是因为我不知道从哪里开始。我在上面搜索了一下,发现了一些关于OAuth的东西。但大部分内容都是针对iOS 5的。

看看
社交.framework
(iOS 6及以上版本)。它管理多个社交网站的身份验证,包括twitter。一旦用户创建了一个帐户并授予您的应用程序访问权限,您就可以使用
SLRequest
执行经过身份验证的twitter(或其他)http请求,而无需直接使用Oauth

首先,您将获得
ACAccount

#import <Social/Social.h>   // SLRequest

- (void)getTwitter {
    ACAccountType *accountType = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    [_accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
            if (granted) {
                // access granted, get account info
                NSArray *accounts = [_accountStore accountsWithAccountType:accountType];
                ACAccount *account = [accounts lastObject];

                // yay, now you can use account for authenticated twitter requests
            } else {
                NSLog(@"Access not granted: %@\n", error);
            }
        }
     ];
}

查看时间线、tweets等信息。

@jycr753我正在查看如何在用户提供用户名和密码的情况下将用户登录到twitter…我能找到的最佳示例是此示例::也可以在此处查看:
- (void)getTwitterAccount:(ACAccount *)account {
    NSString *get = @"https://api.twitter.com/1.1/account/verify_credentials.json";
    NSURL *url = [NSURL URLWithString:get];
    NSDictionary *parms = @{ @"include_entities" : @"false", @"skip_status" : @"true" };

    SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:url parameters:parms ];
    request.account = account;

    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error){
        if(!error) {
            NSLog(@"response: %@\n", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
        } else {
            NSLog(@"performRequestWithHandler error %@\n",  error);
        }
    }];
}