有没有什么办法可以让用户手动登录并创建一个TWTRSession,以便继续与TwitterKit一起使用?我试过了:
NSDictionary *twSessionInfo = [self.accountHelper getTwitterCredential];
TWTRSession *twSession = [[TWTRSession alloc] initWithSessionDictionary:twSessionInfo];
[TwitterKit setValue:twSession forKey:@"_session"];但是Twitter类没有_session属性。任何帮助都将不胜感激。
发布于 2015-05-09 04:22:35
默认登录
通常,使用Twitter登录的最简单方法是使用标准:
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
NSLog(@"Session: %@", session);
NSLog(@"Error: %@", error);
}];自定义登录
然而,如果你真的想使用你自己的登录信息(比如你的应用已经使用了一个自定义的Twitter登录,并且你想迁移到TwitterKit),那么你可以这样做:
TWTRSession *session = [[TWTRSession alloc] initWithAuthToken:@"cwimJSZ3Hatv1" authTokenSecret:@"HdDFPKWPwLj49DH4p4kNz9cX2" userName:@"TestUser323" userID:@"8723892340"];
[[Twitter sharedInstance].sessionStore saveSession:session completion:^(id<TWTRAuthSession> session, NSError *error) {
NSLog(@"Session: %@", session);
NSLog(@"Error: %@", error);
}];https://stackoverflow.com/questions/26990852
复制相似问题