Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

ios - How to get linkedin connections?

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]);
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...