我想顯示用戶個人資料照片和他的個人資料字段,如公司名稱,職位,行業和位置。 我打電話給ProfilePicCall來檢索個人資料圖片。顯示LinkedIn個人資料照片和用戶個人資料使用LinkedIn API
- (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
謝謝。
我沒有得到用戶個人資料網址我使用相同的code.any原因是什麼? –
@ Darshan: - 我使用相同的代碼,它的工作完美,再試一次 – ravinder521986