问题在维基百科API [英] Problem in Wikipedia API
问题描述
我在使用维基百科的API问题。我用这个PHP脚本,
< PHP
$ xmlDoc中=新的DOMDocument();
$xmlDoc->load(\"http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=New_York_Yankees&rvprop=content&format=xml\"); 打印$ xmlDoc-> saveXML();
?>
和我在浏览器中以下结果。为什么呢?
警告:
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.0的
403禁止在D:\\ PROGRAM
文件\\的VertrigoServ \\ WWW \\维基\\的index.php
上线3
警告:DOM文档::负载()
[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 \\维基\\的index.php
上线3
块引用>解决方案有关MediaWiki的用户代理政策:
http://meta.wikimedia.org/wiki/User-Agent_policyI 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?
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
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
解决方案For MediaWiki's User Agent policy: http://meta.wikimedia.org/wiki/User-Agent_policy
这篇关于问题在维基百科API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!