小编Fad*_*dat的帖子

使用LinkedIn API显示LinkedIn的个人资料照片和用户个人资料

我想显示用户个人资料照片和他的个人资料字段,例如公司名称,职位,行业和位置.我调用ProfilePicCall来检索个人资料图片.

- (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:)];
}
Run Code Online (Sandbox Code Playgroud)

然后在图像视图中显示照片我使用下面的代码

- (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 …
Run Code Online (Sandbox Code Playgroud)

objective-c linkedin

0
推荐指数
1
解决办法
1903
查看次数

标签 统计

linkedin ×1

objective-c ×1