维基百科 API 中的问题 [英] Problem in Wikipedia API
问题描述
我在使用维基百科 API 时遇到问题.我使用这个 PHP 脚本,
I have problem using the Wikipedia API. I use this PHP script,
<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load("http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=New_York_Yankees&rvprop=content&format=xml");
print $xmlDoc->saveXML();
?>
我在浏览器中得到以下结果.为什么?
and I have the following result in the browser. Why?
警告:DOMDocument::load(http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=New_York_Yankees&rvprop=content&format=xml)[domdocument.load]:打开失败流:HTTP 请求失败!HTTP/1.0403 禁止在 D:\Program文件\VertrigoServ\www\wiki\index.php第 3 行
Warning: DOMDocument::load(http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=New_York_Yankees&rvprop=content&format=xml) [domdocument.load]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in D:\Program Files\VertrigoServ\www\wiki\index.php on line 3
警告:DOMDocument::load()[domdocument.load]:I/O 警告:无法加载外部实体http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=New_York_Yankees&rvprop=content&format=xml"在 D:\Program文件\VertrigoServ\www\wiki\index.php第 3 行
Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=New_York_Yankees&rvprop=content&format=xml" in D:\Program Files\VertrigoServ\www\wiki\index.php on line 3
推荐答案
对于 MediaWiki 的用户代理策略:http://meta.wikimedia.org/wiki/User-Agent_policy
For MediaWiki's User Agent policy: http://meta.wikimedia.org/wiki/User-Agent_policy
这篇关于维基百科 API 中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!