0
votes

Probably a simple question but I haven't been able to find any tutorials for this. I'm using the linkedin api in java and implementing it on android. I'm able to get education, position and other information but I'm not sure how to retrieve skills. Here's what I have:

private static final String PROFILE_URL = "https://api.linkedin.com/v1/people/~:(id,phone-numbers,headline,educations,positions, skills, recommendations-received)?oauth2_access_token=";

public CareerPluginImpl(final ProviderSupport providerSupport) {
    this.providerSupport = providerSupport;
}

public Career getCareerDetails() throws Exception {
    LOG.info("Fetching career details from " + PROFILE_URL);

    Response serviceResponse = null;
    try {
        serviceResponse = providerSupport.api(PROFILE_URL
                + providerSupport.getAccessGrant().getKey());
    } catch (Exception ie) {
        throw new SocialAuthException(
                "Failed to retrieve the career details from " + PROFILE_URL, ie);
    }
    Element root;
    try {
        root = XMLParseUtil.loadXmlResource(serviceResponse.getInputStream());
    } catch (Exception e) {
        throw new ServerDataException(
                "Failed to parse the career details from response."
                        + PROFILE_URL, e);
    }
    Career career = null;
    if (root != null) {
        career = new Career();
        Education[] educationsArr = null;
        Position[] positionsArr = null;
        Recommendation[] recommendationsArr = null;
        Skill[] skillsArr = null;
        String headline = XMLParseUtil.getElementData(root, "headline");
        career.setHeadline(headline);
        String id = XMLParseUtil.getElementData(root, "id");
        career.setId(id);



// get Skills
        NodeList skills = root
                .getElementsByTagName("skills");
        if (skills != null && skills.getLength() > 0) {
            LOG.debug("skills count "
                    + skills.getLength());

            skillsArr = new Skill[skills.getLength()];
            for (int i = 0; i < skills.getLength(); i++) {
                Skill skillObj = new Skill();
                Element skillEl = (Element) skills.item(i);
                String sid = XMLParseUtil.getElementData(skillEl, "id");
                if (sid != null) {
                    skillObj.setSkillId(sid);
                }
                String text = XMLParseUtil.getElementData(skillEl, "skill");
                if (text != null) {
                    skillObj.setSkillText(text);
                }


                skillsArr[i] = skillObj;
            }
        }

    if (skillsArr != null) {
            career.setSkills(skillsArr);
        }
    }
    return career;
}

The skills list returned with career always seems to come back null. I'm probably not sure about the object I'm trying to get and docs don't really help. Any ideas?

2
did you checked the content of the returned xml?njzk2
I'm not sure how to do that. I'm using eclipseWill

2 Answers

2
votes

I suggest going through the Profile documentation to get an idea of how the Profile API works, as well as which fields are provided. Skills are part of the "Full Profile" set of fields requiring the r_fullprofile member permission:

https://developer.linkedin.com/documents/profile-fields#fullprofile

As an example, the call to retrieve the skill set of the authenticated user would be like this:

http://api.linkedin.com/v1/people/~:(skills)

this should return an xml format which contains the data if i'm right. You have to parse it and make it visable in your app

1
votes

You can get this for the authenticated profile (yourself) but not for your network.

From Linkedin's Connections API reference:

For 1st degree connections, you may only retrieve profile fields available with the r_basicprofile member permission

Unfortunately, Linkedin API is not that open.