How to get linkedin connections?

陌路散爱 提交于 2019-12-25 09:31:24

问题


In my app user has a option to login to app through linkedin.after login i have to get user's connections. when i try to get users connections i am getting response as

{
   "errorCode": 0,
   "message": "Access to connections denied",
   "requestId": "60A0DS1MZE",
   "status": 403,
   "timestamp": 1386682428799
 }

Here is my code

 -(void)GetConnectionsCall
 {
    NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/connections"];

   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(connectionsApiCallResult:didFinish:)
                 didFailSelector:@selector(connectionsApiCallResult:didFail:)];
 }


- (void)connectionsApiCallResult:(OAServiceTicket *)ticket didFinish:(NSData *)data
{
    NSString *responseBody = [[NSString alloc] initWithData:data
                                                   encoding:NSUTF8StringEncoding];
    NSLog(@"connectionsApiCallResult====%@",responseBody);

}

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

回答1:


if you are using OAuth Starter Kit try this . . . .

  1. first go to https://www.linkedin.com/secure/developer edit your App scope , make sure you have checked the r_network scope .

  2. then go to OAuthLoginView of you project , then go to -(void) requestTokenFromProvider method .

edit you scope in below lines .

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"];



回答2:


You need to ask for permissions.. When this is not done you are not allowed to query this information.

Everything documented here: http://developer.linkedin.com/documents/connections-api



来源:https://stackoverflow.com/questions/20496248/how-to-get-linkedin-connections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!