使用post请求在iOS中接收LinkedIn用户配置文件信息

使用post请求在iOS中接收LinkedIn用户配置文件信息,ios,post,linkedin,Ios,Post,Linkedin,我正在寻找一种方法,通过发帖请求检索LinkedIn用户的个人资料信息,我已经阅读了这两个LinkedIn页面,但似乎没有解释太多,或者我无法理解其中的很多内容: 我在stackoverflow上见过这些示例,但我不太了解: http://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,email-address,formatted-name,phonetic-last-name,location:(coun

我正在寻找一种方法,通过发帖请求检索LinkedIn用户的个人资料信息,我已经阅读了这两个LinkedIn页面,但似乎没有解释太多,或者我无法理解其中的很多内容:

我在stackoverflow上见过这些示例,但我不太了解:

http://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,email-address,formatted-name,phonetic-last-name,location:(country:(code)),industry,distance,current-status,current-share,network,skills,phone-numbers,date-of-birth,main-address,positions:(title),educations:(school-name,field-of-study,start-date,end-date,degree,activities)) 
我只想检索网站上出现的技能部分:


有一个非常棒的LinkedIn iOS集成库,您可以使用它调用LinkedIn API。您需要一个访问令牌来拨打电话

打这样的电话:

NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,formatted-name,phonetic-last-name,location:(country:(code)),industry,distance,current-status,current-share,network,skills,phone-numbers,date-of-birth,main-address,positions:(title),educations:(school-name,field-of-study,start-date,end-date,degree,activities))"]];
    OAMutableURLRequest *request = 
    [[OAMutableURLRequest alloc] initWithURL:url
                                    consumer:oAuthLoginView.consumer
                                       token: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:)];    

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

    NSDictionary *profile = [responseBody objectFromJSONString];

    if ( profile )
    {
        name.text = [[NSString alloc] initWithFormat:@"%@ %@",
                     [profile objectForKey:@"firstName"], [profile objectForKey:@"lastName"]];
        headline.text = [profile objectForKey:@"headline"];

        .....and get skills and other user details

     }    
}
NSString *basicConnectionInfo = [NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name)?oauth2_access_token=%@&format=json", accessToken];

有一个很棒的LinkedIn iOS集成库,您可以使用它调用LinkedIn API。您需要一个访问令牌来拨打电话

打这样的电话:

NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,formatted-name,phonetic-last-name,location:(country:(code)),industry,distance,current-status,current-share,network,skills,phone-numbers,date-of-birth,main-address,positions:(title),educations:(school-name,field-of-study,start-date,end-date,degree,activities))"]];
    OAMutableURLRequest *request = 
    [[OAMutableURLRequest alloc] initWithURL:url
                                    consumer:oAuthLoginView.consumer
                                       token: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:)];    

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

    NSDictionary *profile = [responseBody objectFromJSONString];

    if ( profile )
    {
        name.text = [[NSString alloc] initWithFormat:@"%@ %@",
                     [profile objectForKey:@"firstName"], [profile objectForKey:@"lastName"]];
        headline.text = [profile objectForKey:@"headline"];

        .....and get skills and other user details

     }    
}
NSString *basicConnectionInfo = [NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name)?oauth2_access_token=%@&format=json", accessToken];
使用工具:

获取技能列表的API:

我在控制台工具中尝试了它,并且能够为我的个人资料获取技能。我认为上述要求的个人技能ID应该有助于您获得更多信息。试试看

使用工具:

获取技能列表的API:


我在控制台工具中尝试了它,并且能够为我的个人资料获取技能。我认为上述要求的个人技能ID应该有助于您获得更多信息。试试看

我有相当多的使用linkedIn API的经验。已经有一段时间了,但希望这能让你走上正轨

要从作为您的连接之一的链接用户处获取配置文件信息,您需要以下格式:

NSString *theRequest = [NSString stringWithFormat:@"https://api.linkedin.com/v1/people/id=abc123:(first-name,last-name,picture-url,location:(name))?oauth2_access_token=%@&format=json", accessToken];
此请求将返回具有指定id的用户的名字、姓氏、配置文件图片url和位置

您可以在此处查看linkedIn关于其配置文件字段描述的文档,以查看可请求的字段类型列表:

如果您想知道如何获取您首先要请求其配置文件信息的用户的id,您可以请求所有连接的一些基本信息(包括id),如下所示:

NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,formatted-name,phonetic-last-name,location:(country:(code)),industry,distance,current-status,current-share,network,skills,phone-numbers,date-of-birth,main-address,positions:(title),educations:(school-name,field-of-study,start-date,end-date,degree,activities))"]];
    OAMutableURLRequest *request = 
    [[OAMutableURLRequest alloc] initWithURL:url
                                    consumer:oAuthLoginView.consumer
                                       token: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:)];    

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

    NSDictionary *profile = [responseBody objectFromJSONString];

    if ( profile )
    {
        name.text = [[NSString alloc] initWithFormat:@"%@ %@",
                     [profile objectForKey:@"firstName"], [profile objectForKey:@"lastName"]];
        headline.text = [profile objectForKey:@"headline"];

        .....and get skills and other user details

     }    
}
NSString *basicConnectionInfo = [NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name)?oauth2_access_token=%@&format=json", accessToken];
此请求将为您提供所有连接的id、名字和姓氏。在获得想要的人的id后,可以使用用户的id发出请求(如第一个示例所示)

现在让我们来看看有点不幸的消息。。。如果您遵循上面提供的链接,您会注意到技能字段是“可向LinkedIn开发者申请的成员配置文件字段”的一部分。我假设您必须遵循他们提供的链接:才能访问技能成员配置文件字段


我还没有申请LinkedIn。所以,我还没有测试过对技能领域的呼叫。但是,我猜它将类似于我向您展示的示例。希望这有帮助

我有相当多的使用linkedIn API的经验。已经有一段时间了,但希望这能让你走上正轨

要从作为您的连接之一的链接用户处获取配置文件信息,您需要以下格式:

NSString *theRequest = [NSString stringWithFormat:@"https://api.linkedin.com/v1/people/id=abc123:(first-name,last-name,picture-url,location:(name))?oauth2_access_token=%@&format=json", accessToken];
此请求将返回具有指定id的用户的名字、姓氏、配置文件图片url和位置

您可以在此处查看linkedIn关于其配置文件字段描述的文档,以查看可请求的字段类型列表:

如果您想知道如何获取您首先要请求其配置文件信息的用户的id,您可以请求所有连接的一些基本信息(包括id),如下所示:

NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,formatted-name,phonetic-last-name,location:(country:(code)),industry,distance,current-status,current-share,network,skills,phone-numbers,date-of-birth,main-address,positions:(title),educations:(school-name,field-of-study,start-date,end-date,degree,activities))"]];
    OAMutableURLRequest *request = 
    [[OAMutableURLRequest alloc] initWithURL:url
                                    consumer:oAuthLoginView.consumer
                                       token: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:)];    

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

    NSDictionary *profile = [responseBody objectFromJSONString];

    if ( profile )
    {
        name.text = [[NSString alloc] initWithFormat:@"%@ %@",
                     [profile objectForKey:@"firstName"], [profile objectForKey:@"lastName"]];
        headline.text = [profile objectForKey:@"headline"];

        .....and get skills and other user details

     }    
}
NSString *basicConnectionInfo = [NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name)?oauth2_access_token=%@&format=json", accessToken];
此请求将为您提供所有连接的id、名字和姓氏。在获得想要的人的id后,可以使用用户的id发出请求(如第一个示例所示)

现在让我们来看看有点不幸的消息。。。如果您遵循上面提供的链接,您会注意到技能字段是“可向LinkedIn开发者申请的成员配置文件字段”的一部分。我假设您必须遵循他们提供的链接:才能访问技能成员配置文件字段


我还没有申请LinkedIn。所以,我还没有测试过对技能领域的呼叫。但是,我猜它将类似于我向您展示的示例。希望这有帮助

如果有人正在阅读此答案,则截至2015年5月,LinkedIn API的访问权限有限。您需要申请他们的apply with LinkedIn程序才能访问完整的个人资料字段,包括技能


如果有人正在阅读此答案,则截至2015年5月,LinkedIn API的访问权限有限。您需要申请他们的apply with LinkedIn程序才能访问完整的个人资料字段,包括技能


但是在哪里添加用户名?还需要密码吗?我猜你是在询问用户的linkedin帐户。库中有一个视图,该视图将该视图推送至询问用户名和密码。一旦获得了权限,您就可以进行这些调用。当我运行项目时,它会要求进行身份验证,这就是您获得accessToken的时候。图书馆会自动为你做这件事。只需使用它克里斯汀·琼斯图书馆充满了漏洞和问题,这是正常的,因为它是在几年前建立的,谢谢你,但我在哪里添加用户名?还需要密码吗?我猜你是在询问用户的linkedin帐户。库中有一个视图,该视图将该视图推送至询问用户名和密码。一旦获得了权限,您就可以进行这些调用。当我运行项目时,它会要求进行身份验证,这就是您获得accessToken的时候。图书馆会自动为你做这件事。只需使用它Kristen Jones库充满了bug和问题,自几年前构建以来,这是正常的,感谢您尝试使用:@“”,但它返回一个空字符串尝试使用:@“”,但它返回一个空字符串OK,显然是因为我做了一个type-o错误,调用后返回的结果是:{id=eOZWq36nxC;