公開API活用ガイド (I・O BOOKS)にSimpleAPIのWikipedia APIの開設があったのでお試し。
メモ
- リクエストURL:http://wikipedia.simpleapi.net/api?keyword=xxx
- simplexml_load_file()でコンテンツ取得
- 戻りのbodyを表示
確認ページ:hello_simpleapi_wikipedia.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SimpleAPI "Wikipedia" test</title>
</head>
<body>
<h1>SimpleAPI "Wikipeadia" test</h1>
<form method="GET" action="">
<input type="text" name="keyword" size="40" value="" />
<input type="submit" value="検索" />
</form>
<br>
<?php
if (isset($_GET['keyword'])) {
$keyword = urlencode($_GET['keyword']);
$url = "http://wikipedia.simpleapi.net/api?keyword=".$keyword."&output=xml";
$xml = simplexml_load_file($url);
if ($xml) {
echo $xml->result->body;
}
else {
echo "simplexml_load_fileでエラー";
}
}
?>
</body>
</html>
何件か検索してみたけど、あまりヒットしない。。
MediaWiki APIというのがあるみたいだから、こっちを試してみようと思う。
参考サイト
公開API活用ガイド (I・O BOOKS)
posted with amazlet at 12.03.13
ZAPA
工学社
売り上げランキング: 19754
工学社
売り上げランキング: 19754
関連エントリー
