Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.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 api集成中获取电子邮件和用户名?_Ios_Objective C_Swift_Xcode_Twitter - Fatal编程技术网

Ios 如何从Twitter api集成中获取电子邮件和用户名?

Ios 如何从Twitter api集成中获取电子邮件和用户名?,ios,objective-c,swift,xcode,twitter,Ios,Objective C,Swift,Xcode,Twitter,下面是一些从twitterapi获取详细信息的代码。我是iOS应用程序中Twitter集成的新手。我是这个实现的新手 -(void)TwitterAction { TWTRSessionStore *store = [[Twitter sharedInstance] sessionStore]; NSString *userID = store.session.userID; if (userID) [store logOutUserID:userID];

下面是一些从twitterapi获取详细信息的代码。我是iOS应用程序中Twitter集成的新手。我是这个实现的新手

-(void)TwitterAction {

TWTRSessionStore *store = [[Twitter sharedInstance] sessionStore];
    NSString *userID = store.session.userID;
    if (userID)
        [store logOutUserID:userID];
    [[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
        if (session) {
            [self usersShow:session.userID];

        } else
            NSLog(@"Error: %@", [error localizedDescription]);
    }];
}

-(void)usersShow:(NSString *)userID {

//NSString *statusesShowEndpoint =[NSString stringWithFormat:@"https://api.twitter.com/1.1/favorites/create.json?id=%@",userID];

NSString *statusesShowEndpoint = @"https://api.twitter.com/1.1/users/show.json";
NSDictionary *params = @{@"user_id": userID};
NSError *clientError;
TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser];
NSURLRequest *request = [client URLRequestWithMethod:@"GET" URL:statusesShowEndpoint parameters:params error:&clientError];
if (request)
{
    [client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        if (data)
        {
            // handle the response data e.g.
            NSError *jsonError;
            NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
            userDict = @{@"name":[self dictonaryContainKey:json key:@"name"],@"imageUrl":[self dictonaryContainKey:json key:@"profile_image_url"],@"userName":[self dictonaryContainKey:json key:@"screen_name"],@"email":[self dictonaryContainKey:json key:@"gmail"],@"gender":[self dictonaryContainKey:json key:@"gender"]};

            [self CreateAccountBySocialNetworks];

        }
        else
            NSLog(@"Error code: %ld | Error description: %@", (long)[connectionError code], [connectionError localizedDescription]);
    }];
}
else
    NSLog(@"Error: %@", clientError);



}

可以向用户请求电子邮件地址,但需要将应用程序列入白名单。
请参阅:

这是您的完整代码吗?你测试过了吗?结果如何?“检查此代码!”是不够的。假装它是危险的,以问题的形式组织你的帖子。嗨,你能检查我的问题吗?我更新它@soraky这里仍然没有具体的问题陈述。你到底遇到了什么问题?我需要来自twitter的电子邮件和用户名,所以我只使用上面的代码@halfer“我需要来自twitter的电子邮件和用户名”是什么意思?谁的电子邮件和用户名?这个人正在通过基于Twitter的身份验证系统吗?