我想显示用户 Profiles 照片和他的 Profiles 字段,例如公司名称,职位,行业和位置 . 我调用ProfilePicCall来检索 Profiles 图片 .
- (void)ProfilePicCall
{
NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/picture-url"];
OAMutableURLRequest *request =
[[OAMutableURLRequest alloc] initWithURL:url
consumer:oAuthLoginView.consumer
token:oAuthLoginView.accessToken
callback:nil
signatureProvider:nil];
NSLog(@"the request is %@",request);
[request setValue:@"json" forHTTPHeaderField:@"x-li-format"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(profileApiCallResult:didFinish:)
didFailSelector:@selector(profileApiCallResult:didFail:)];
}
然后在图像视图中显示照片我使用下面的代码
- (void)profileApiCallResult:(OAServiceTicket *)ticket didFinish:(NSData *)data
{
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSDictionary *profile = [responseBody objectFromJSONString];
// [responseBody release];
if ( profile )
{
NSLog(@"Profile is %@",profile);
NSString *picture_url = [[NSUserDefaults standardUserDefaults]valueForKey:@"linkedid_Profile_url"];
NSURL *imageurl = [NSURL URLWithString:picture_url];
NSData *imagedata = [[NSData alloc]initWithContentsOfURL:imageurl];
UIImage *image = [UIImage imageWithData: imagedata];
[LinkedInPicture setImage:image];
}
else
{
NSDictionary *profile = [responseBody objectFromJSONString];
NSLog(@"last path componemt is %@",profile);
}
// The next thing we want to do is call the network updates
[self networkApiCall];
[[NSUserDefaults standardUserDefaults] setValue:@"Used" forKey:@"linkedin"];
}
但图像不显示在图像视图中 . 请帮我显示图片,以及如何使用LinkedIn API
谢谢 .
2 回答
我找到了我的问题的解决方案,它应该将LinkedIn API调用更改为:
谢谢 .
我不喜欢上面的方法,
首先,我使用这个库来帮助使用Auth2.0 for LinkedIn进行日志记录过程https://github.com/jeyben/IOSLinkedInAPI
使用如下或阅读文档并自行更改代码 .
解决方案是这个请求https://api.linkedin.com/v1/people/~:(picture-url)?oauth2_access_token=&format = json
对我来说很好