2

我想从我的 LinkedIn 个人资料中获取我所有的朋友。请建议我任何教程。

我的代码是:

NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name,email-address,picture-url,Positions)"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
                                                               consumer:self.oAuthLoginView.consumer
                                                                  token:self.oAuthLoginView.accessToken
                                                               callback:nil
                                                      signatureProvider:nil];

[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:)];
4

2 回答 2

0

您可以将其用于连接:对于请求部分,请参阅此。

- (void)connectionsApiCallResult:(LOAServiceTicket *)ticket didFinish:(NSData *)data
    {
        NSString *responseBody = [[NSString alloc] initWithData:data
                                                       encoding:NSUTF8StringEncoding];

        NSLog(@"connectionsApiCallResult====%@",responseBody);

        [responseBody release];
    }

    - (void)connectionsApiCallResult:(LOAServiceTicket *)ticket didFail:(NSError *)error
    {
        NSLog(@"%@",[error description]);

    }

    -(void)GetConnectionsCall
    {
        NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/connections:(headline,first-name,last-name,picture-url,id)"];

        LOAMutableURLRequest *request =
        [[LOAMutableURLRequest alloc] initWithURL:url
                                        consumer:self.consumer
                                           token:TestAccessToken
                                        callback:nil
                               signatureProvider:nil];

        [request setValue:@"json" forHTTPHeaderField:@"x-li-format"];

        LOADataFetcher *fetcher = [[[LOADataFetcher alloc] init] autorelease];
        [fetcher fetchDataWithRequest:request
                             delegate:self
                    didFinishSelector:@selector(requestTokenResult:didFinish:)
                      didFailSelector:@selector(requestTokenResult:didFail:)];

    }
于 2013-09-10T09:21:35.663 回答
0

请尝试以下步骤

  1. 首先去https://www.linkedin.com/secure/developer编辑你的 App 范围,确保你已经检查了 r_network 范围。
  2. 然后转到您项目的OAuthLoginView,然后转到-(void) requestTokenFromProvider方法。

在下面的行中编辑您的范围。

OARequestParameter *nameParam = [[OARequestParameter alloc] initWithName:@"scope"
value:@"r_fullprofile+rw_nus+r_network"];

OARequestParameter * scopeParameter=[OARequestParameter requestParameter:@"scope" 
value:@"r_fullprofile rw_nus r_network"];
于 2014-11-25T13:14:25.047 回答