我想從維基百科使用捲髮獲取頁面摘要。我的代碼是維基百科捲髮請求錯誤
<?php
$title = <input from user>;
$url = 'http://en.wikipedia.org/w/api.php?action=query&titles='.$title.'&format=xml&prop=revisions&rvprop=content&redirects';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_USERAGENT, 'testing wikipedia services');
$result = curl_exec($curl);
print $result;
//$content = $c->query->pages->page->revisions->rev;
//print $content;
?>
我最初想測試代碼,看看我的代碼是否返回整個頁面。但我得到它說
Request: [unknown method] http://en.wikipedia.org:80/w/api.php?action=query&titles=US Environmental Protection Agency&format=xml&prop=revisions&rvprop=content&redirects, from 161.80.8.53 via cp1005.eqiad.wmnet (squid/2.7.STABLE9) to [unknown host] ([unknown]) Error: ERR_INVALID_URL, errno [No Error] at Tue, 04 Dec 2012 16:55:52 GMT
的URL作品的錯誤,但它仍然會產生未知的方法錯誤!