我尝试从返回此 XML的 facebook API 解析结果:
<links_getStats_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
<link_stat>
<url>http://www.facebook.com</url>
<normalized_url>http://www.facebook.com/</normalized_url>
<share_count>1624678</share_count>
<like_count>928267</like_count>
<comment_count>150197</comment_count>
<total_count>2703142</total_count>
<click_count>949</click_count>
<comments_fbid>405613579725</comments_fbid>
<commentsbox_count>2328</commentsbox_count>
</link_stat>
</links_getStats_response>
我想获得 Facebook 喜欢的数量。
这是我的代码:
$apiFacebook="http://api.facebook.com/restserver.php?method=links.getStats&urls=http://www.facebook.com";
$parse = simplexml_load_file($apiFacebook);
$count = $parse->xpath("/links_getStats_response/link_stat/like_count");
print_r($count);
路径有问题吗?