我正在尝试通过Twitter添加登录和注册到我的应用程序这是我获取Twitter用户信息的代码:
-(void) initWithTwitterUser{
[SVProgressHUD show];
_nameField.text = [PFTwitterUtils twitter].screenName;
// TODO find a way to fetch details with Twitter..
PFUser *user = [PFUser currentUser];
NSString * requestString = [NSString stringWithFormat:@"https://api.twitter.com/1.1/users/show.json?screen_name=%@", [PFTwitterUtils twitter].screenName];
NSURL *verify = [NSURL URLWithString:requestString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:verify];
[[PFTwitterUtils twitter] signRequest:request];
// TODO find a way to fetch details with Twitter..
NSURLResponse *response = nil;
NSError *error = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
if (!error){
NSDictionary* result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
NSLog(@"%@",result);
[user setObject:[result objectForKey:@"profile_image_url_https"]
forKey:@"picture"];
// does this thign help?
[user setUsername:[result objectForKey:@"screen_name"]];
NSString * names = [result objectForKey:@"name"];
NSMutableArray * array = [NSMutableArray arrayWithArray:[names componentsSeparatedByString:@" "]];
if ( array.count > 1){
[user setObject:[array lastObject]
forKey:@"last_name"];
[array removeLastObject];
[user setObject:[array componentsJoinedByString:@" " ]
forKey:@"first_name"];
}
} else
NSLog(@"Error : %@ ", [error userInfo]);
}
通过Twitter登录工作正常但登录后我尝试获取用户信息时出现此问题
错误:{ NSErrorFailingURLKey =“https://api.twitter.com/1.1/users/show.json?screen_name=karizma_ltd”; NSErrorFailingURLStringKey =“https://api.twitter.com/1.1/users/show.json?screen_name=karizma_ltd”; NSUnderlyingError =“错误域= kCFErrorDomainCFNetwork代码= -1012 \”操作无法完成。 (kCFErrorDomainCFNetwork错误-1012。)\“UserInfo = 0x15ec8bc0 {_kCFURLErrorAuthFailedResponseKey = {url = https://api.twitter.com/1.1/users/show.json?screen_name=karizma_ltd}}”; }
答案 0 :(得分:0)
这是与parse.com sdk版本1.8.1
或1.8.0
相关的错误,我不记得确切的版本抱歉,它已在下一个sdk版本中得到解决