本文介绍了如何在iOS的Twitter资料图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了下面code:
NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1.1/users/show.json"];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:username, @"screen_name" ,[[controller.engine accessToken] secret]];
TWRequest *request = [[TWRequest alloc] initWithURL:url parameters:params requestMethod:TWRequestMethodGET];
[request performRequestWithHandler:
^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if (responseData) {
NSDictionary *user = [NSJSONSerialization JSONObjectWithData:responseData
options:NSJSONReadingAllowFragments
error:NULL];
NSString *profileImageUrl = [user objectForKey:@"profile_image_url"];
NSLog(@"%@",profileImageUrl);
}
}];
但我总是最后得到一个坏认证
错误。我觉得我失去了一些东西。会有人请检查我的code?或提供任何建议,以获取Twitter的用户配置文件照片?
But I always end up getting a Bad authentication
error. I feel I'm missing something. Would anyone please check my code? Or provide any suggestions to retrieve twitter user profile pictures?
感谢
推荐答案
你有没有使用这种第三方Twitter的引擎考虑?我用具备相当的成功,似乎是正在积极发展。
Have you considered using a 3rd party Twitter engine for this? I've used FHSTwitterEngine with a fair amount of success, and it seems to be under active development.
要拉个人资料图片,你会做这样的事情:
To pull a profile picture you would do something like this:
[[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:@"<consumer_key>" andSecret:@"<consumer_secret>"];
[[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:self
withCompletion:^(BOOL success) {
if (success) {
UIImage *profileImg = [[FHSTwitterEngine sharedEngine] getProfileImageForUsername:@"<username>" andSize:size];
}
}];
这篇关于如何在iOS的Twitter资料图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!