Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinkedIn Id getting null for android

I am using following code snippet to get userdetail, but getting Id null from profile.getId()

@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());
    }

please give me any suggestion to get it.

like image 831
Chirag_CID Avatar asked Jun 15 '12 13:06

Chirag_CID


1 Answers

I have got solution for this, I have used following code snippet to get more detail for user and now it is giving all properly,

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());
like image 126
Chirag_CID Avatar answered Sep 23 '22 03:09

Chirag_CID