6

我正在使用以下代码片段来获取 userdetail,但从profile.getId()获取 Id null

@Override
    protected void onNewIntent(Intent intent) {
        String verifier = intent.getData().getQueryParameter("oauth_verifier");

        LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(
                liToken, verifier);
        client = factory.createLinkedInApiClient(accessToken);
        client.postNetworkUpdate("LinkedIn Android app test");
        Person profile = client.getProfileForCurrentUser();

        System.out.println("PersonID : " + profile.getId());
        System.out.println("Name : " + profile.getFirstName() + " "
                + profile.getLastName());
    }

请给我任何建议来获得它。

4

1 回答 1

10

我已经找到了解决方案,我使用了以下代码片段来为用户获取更多详细信息,现在它可以正确提供所有内容,

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));
        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());
于 2012-06-16T06:07:27.787 回答