如何在 iOS SDK 中獲取 LinkedIn 連接/朋友/聯繫人? (How to fetch LinkedIn connections/Friends/Contacts in iOS SDK?)


問題描述

如何在 iOS SDK 中獲取 LinkedIn 連接/朋友/聯繫人? (How to fetch LinkedIn connections/Friends/Contacts in iOS SDK?)

I want to fetch all my friends from my LinkedIn profile. Please suggest me any tutorial.

My code is :

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

參考解法

方法 1:

You can use this for connections:For request part see this.

‑ (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:)];

    }

方法 2:

Please try the following steps 

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

(by Gagan AggarwalImranNitin)

參考文件

  1. How to fetch LinkedIn connections/Friends/Contacts in iOS SDK? (CC BY‑SA 3.0/4.0)

#linkedin #iphone #iOS






相關問題

php中需要LinkedIn類型的朋友連接 (LinkedIn type friends connection required in php)

我可以在沒有明確用戶批准的情況下獲得 Linkedin oauth 訪問令牌嗎? (Could I get Linkedin oauth access token without explicitly user approve?)

Rails 3 Linkedin API 寶石 (Rails 3 Linkedin API gem)

如何在 iOS SDK 中獲取 LinkedIn 連接/朋友/聯繫人? (How to fetch LinkedIn connections/Friends/Contacts in iOS SDK?)

Linkedin 應用程序具有 OAuth 用戶令牌和 OAuth 用戶密鑰,它們會過期嗎? (Linkedin Application has OAuth User Token and OAuth User Secret, Do they Expire?)

LinkedIn 獲取個人資料提要或新聞提要 2015 (LinkedIn get profile feed or news feed 2015)

OAuth2::LinkedIn 錯誤 (OAuth2::Error with LinkedIn)

如果 Android 中未安裝 LinkedIn 本機應用程序,如何使用 LinkedIn 登錄和發布? (How to login and post with LinkedIn if LinkedIn native app is not installed in android?)

使用 JS API 集成 LinkedIn 登錄 (Integrate LinkedIn login using JS API)

Linkedin oauth2 r_liteprofile 沒有從 api 返回 (Linkedin oauth2 r_liteprofile not being returned from api)

LinkedIn OAuth2.0 使會話無效/強制重新授權 (LinkedIn OAuth2.0 Invalidate Session / Force re-authorization)

LinkedIn API v2 獲取用戶信息 (LinkedIn API v2 get user info)







留言討論