【发布时间】:2015-04-04 22:41:11
【问题描述】:
可能是一个简单的问题,但我找不到任何教程。我在java中使用linkedin api并在android上实现它。我能够获得教育、职位和其他信息,但我不知道如何检索技能。这是我所拥有的:
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;
}
与职业一起返回的技能列表似乎总是返回为空。我可能不确定我想要获取的对象,文档并没有真正的帮助。有什么想法吗?
【问题讨论】:
-
你检查返回的xml的内容了吗?
-
我不知道该怎么做。我正在使用日食