我正在尝试使用MediaWiki获取维基百科页面(来自特定类别)。为此,我正在关注this教程清单3.列出类别中的页面。我的问题是:如何在不使用Zend Framework的情况下获取Wikipedia页面?有没有基于PHP的休息客户端,而无需安装?因为Zend需要首先安装他们的软件包,并且需要一些配置......我不想完成所有这些工作。将维基百科API与其他客户端一起使用
谷歌搜索和一些调查后,我发现了一个名为cURL的工具,使用PHP的cURL也可以建立一个休息服务。我在执行休息服务真的很新,但已经试图在PHP中实现的东西:
<?php
header('Content-type: application/xml; charset=utf-8');
function curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$wiki = "http://de.wikipedia.org/w/api.php?action=query&list=allcategories&acprop=size&acprefix=haut&format=xml";
$result = curl($wiki);
var_dump($result);
?>
,但得到的结果的误差。任何人都可以提供帮助吗?
UPDATE:
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
如果你告诉我们错误是什么,它可能会有所帮助。 – 2013-03-14 19:53:12
@IlmariKaronen请看看问题的'update'部分。 – Dozent 2013-03-14 20:48:21