やあみんな!:) Facebook APIからいいね、シェアなどの数を取得するサービスに取り組んでいます。しかし、fqlResponse.getChild()からnullpointer例外が発生するため、問題があります。
私の意見では、xmls doctypeの自動検出に問題があるため、doctypeを手動で定義しましたが、問題はまだ存在します。たぶん、Facebookのxml doctypeは正しくありませんか?キャッチ方法は次のとおりです。
public void refreshLikesSharesClicksAndTotal() throws JDOMException, IOException {
URL fqlURL = new URL("https://api.facebook.com/method/fql.query?query=select like_count, total_count, share_count, click_count from link_stat where url=\"" + this.url.toString() + "\"");
Document inputXML = new SAXBuilder().build(fqlURL);
DocType docType = new DocType("xml", "http://www.w3.org/2001/XMLSchema-instance");
inputXML.setDocType(docType);
Element fqlResponse = inputXML.getRootElement().getChild("link_stat");
Element likes = fqlResponse.getChild("like_count");
logger.info("Likes: " + likes.getText());
Element shares = fqlResponse.getChild("share_count");
Element clicks = fqlResponse.getChild("click_count");
Element total = fqlResponse.getChild("total_count");
this.likes = Integer.parseInt(likes.getText());
this.shares = Integer.parseInt(shares.getText());
this.clicks = Integer.parseInt(clicks.getText());
this.total = Integer.parseInt(total.getText());
}
ドイツ語の問題の説明: http ://www.java-forum.org/xml-co/118648-problem-beim-parsen-facebook-xml.html
手伝ってくれてありがとう!whitenexx