2013-05-23 2 views
5

나는 지금 기본 인증을 받았지만 이메일 주소를받지 못하고 인증 한 후 linkedin 사용자로부터 전자 메일 주소를 얻으려고합니다.linkedin에서 이메일 주소를 가져 오지 못하셨습니까?

인증을 위해 http://code.google.com/p/linkedin-j/downloads/list jar 파일을 사용합니다.

이 문서를 자세히 읽었지만 완전히 사용하지 않습니다. http://oodlestechnologies.com/blogs/recent-changes-in-linkedin-api. jar 파일 속성에 대한 코드 아래

: -

# API URLs 
########## 
# Profile API 
com.google.code.linkedinapi.client.getProfileForCurrentUser=http://api.linkedin.com/v1/people/~{profileFields} 
com.google.code.linkedinapi.client.getProfileById=http://api.linkedin.com/v1/people/id={id}{profileType}{profileFields} 
com.google.code.linkedinapi.client.getProfileByUrl=http://api.linkedin.com/v1/people/url={url}{profileType}{profileFields} 

#OAuth URLs 
########### 
com.google.code.linkedinapi.client.oauth.requestToken=https://api.linkedin.com/uas/oauth/requestToken 
com.google.code.linkedinapi.client.oauth.accessToken=https://api.linkedin.com/uas/oauth/accessToken 
com.google.code.linkedinapi.client.oauth.authorize=https://www.linkedin.com/uas/oauth/authorize 
com.google.code.linkedinapi.client.oauth.invalidateToken=https://api.linkedin.com/uas/oauth/invalidateToken 

내가 위 생성 항아리의 표시 오류에 아무것도에 변화를 해요

. 지금

내 코드를 같이 메신저 : -

void startAutheniticate() { 

     System.out.println("OAUTH_CALLBACK_URL " + OAUTH_CALLBACK_URL); 

     final LinkedInRequestToken liToken = oAuthService 
       .getOAuthRequestToken(OAUTH_CALLBACK_URL); 
     final String uri = liToken.getAuthorizationUrl(); 
     getSharedPreferences(OAUTH_PREF, MODE_PRIVATE).edit() 
       .putString(PREF_REQTOKENSECRET, liToken.getTokenSecret()) 
       .commit(); 


     Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); 
     startActivity(i); 
    } 


void finishAuthenticate(final Uri uri) { 
     if (uri != null && uri.getScheme().equals(OAUTH_CALLBACK_SCHEME)) { 
      final String problem = uri.getQueryParameter(OAUTH_QUERY_PROBLEM); 
      if (problem == null) { 
       final SharedPreferences pref = getSharedPreferences(OAUTH_PREF, 
         MODE_PRIVATE); 
       final LinkedInAccessToken accessToken = oAuthService 
         .getOAuthAccessToken(
           new LinkedInRequestToken(uri 
             .getQueryParameter(OAUTH_QUERY_TOKEN), 
             pref.getString(PREF_REQTOKENSECRET, 
               null)), 
           uri.getQueryParameter(OAUTH_QUERY_VERIFIER)); 
       pref.edit() 
         .putString(PREF_TOKEN, accessToken.getToken()) 
         .putString(PREF_TOKENSECRET, 
           accessToken.getTokenSecret()) 
         .remove(PREF_REQTOKENSECRET).commit(); 
       showCurrentUser(accessToken); 
      } else { 
       Toast.makeText(this, 
         "Appliaction down due OAuth problem: " + problem, 
         Toast.LENGTH_LONG).show(); 
       finish(); 
      } 

     } 
    } 


void clearTokens() { 
     getSharedPreferences(OAUTH_PREF, MODE_PRIVATE).edit() 
       .remove(PREF_TOKEN).remove(PREF_TOKENSECRET) 
       .remove(PREF_REQTOKENSECRET).commit(); 
    } 

    void showCurrentUser(final LinkedInAccessToken accessToken) { 

     final LinkedInApiClient client = factory 
       .createLinkedInApiClient(accessToken); 
     try { 

      final Person profile = client.getProfileForCurrentUser(EnumSet.of(
        ProfileField.ID, ProfileField.FIRST_NAME, 
        ProfileField.LAST_NAME, ProfileField.HEADLINE, 
        ProfileField.INDUSTRY, ProfileField.PICTURE_URL, 
        ProfileField.DATE_OF_BIRTH, ProfileField.LOCATION_NAME, 
        ProfileField.MAIN_ADDRESS, ProfileField.LOCATION_COUNTRY 
        )); 

      // ///////////////////////////////////////////////////////// 
      // here you can do client API calls ... 
      // client.postComment(arg0, arg1); 
      // client.updateCurrentStatus(arg0); 
      // or any other API call (this sample only check for current user 
      // and shows it in TextView) 
      // ///////////////////////////////////////////////////////// 


      System.out.println("p => " + profile); 
      System.out.println("PersonID : " + profile.getId()); 
      System.out.println("Name : " + profile.getFirstName() + " " 
        + profile.getLastName()); 
      System.out.println("Headline : " + profile.getHeadline()); 
      System.out.println("Industry : " + profile.getIndustry()); 
      System.out.println("Picture : " + profile.getPictureUrl()); 
      DateOfBirth dateOfBirth = profile.getDateOfBirth(); 
      System.out.println("DateOfBirth : " + dateOfBirth.getDay() + "/" 
        + dateOfBirth.getMonth() + "/" + dateOfBirth.getYear()); 
      System.out.println("MAin Address : " + profile.getMainAddress()); 
      Location location = profile.getLocation(); 
      System.out.println("Location:" + location.getName() + " - " 
        + location.getCountry().getCode()); 
      // get_from_last 


      Toast.makeText(LITestActivity.this, "Wait...", Toast.LENGTH_LONG).show(); 



      startActivity(new Intent(LITestActivity.this, 
        UserProfileScreen.class) 
        .putExtra("get_from_last", "1") 
        .putExtra("getId", profile.getId()) 
        .putExtra("getEmail", "[email protected]") 
        .putExtra("getFirstName", profile.getFirstName()) 
        .putExtra("getLastName", profile.getLastName()) 
        .putExtra("getHeadline", profile.getHeadline()) 
        .putExtra("getPictureUrl", profile.getPictureUrl()) 
        .putExtra(
          "dob", 
          dateOfBirth.getDay() + "/" + dateOfBirth.getMonth() 
            + "/" + dateOfBirth.getYear())); 

      finish(); 
     } catch (LinkedInApiClientException ex) { 
      clearTokens(); 
      Toast.makeText(
        this, 
        "Appliaction down due LinkedInApiClientException: " 
          + ex.getMessage() 
          + " Authokens cleared - try run application again.", 
        Toast.LENGTH_LONG).show(); 
      pd.dismiss(); 
      finish(); 
     } 

    } 

    int i = 0; 

    public void onNewIntent(Uri intent) { 

     if (i == 0) { 
      i++; 
      finishAuthenticate(intent); 
     } else { 
      i++; 
     } 
     System.out.println("i => " + i); 
    } 

하지만 메신저 그래서 하나, 나는 그것의 가치를 오래된 질문 생각은 비록 나에게

답변

17

을 도울 수있는 이메일 주소를 얻는 방법을 붙어 대답. LinkedIn에서 linkedin-j-android 라이브러리를 사용하여 사용자 이메일 주소를 가져 오는 방법을 찾기 위해 많은 어려움을 겪었습니다. 불행히도 솔루션을 사용할 준비가되지 않았으므로 라이브러리 소스를 변경하고 패키지에 다시 패키지하여 응용 프로그램에서 사용하도록했습니다. 이 링크에서 라이브러리를 다운로드 할 수 있습니다. https://dl.dropboxusercontent.com/u/46373731/linkedin-j-android.jar

전자 메일 주소를 가져 오는 데 ProfileField.EMAIL_ADDRESS를 사용할 수 있습니다.

+0

나를 위해 일하는 지금 yepeeeeee !!!!!!!!! – duggu

+0

연락처는 어떻게받을 수 있습니까? – Arpit

+1

https://github.com/jenuprasad/LinkedinEmailIdSampleapp – jenuine

관련 문제