有名人の周辺情報取得

久しぶりにAPIのタグを使います。

bayashi.jp

というAPIが公開されていたのを見て作ってみました。
簡単すぎるほど簡単ですけど。
有名人の名前を入れたら周辺データのリンクが作成されるものです。

有名人の周辺情報

以下ソース

<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>有名人の周辺情報</title>
<META NAME="GENERATOR" CONTENT="mi">
有名人の名前を入れてね!
<form method="POST" action="index.php">
<input type="text" name="word"><br>
<input type="submit" value="送信">
 <input type="reset" value="取消">
</form>
<?php
$ref=$_POST["word"];

if($ref != null){
$ref=mb_convert_encoding($ref,"UTF-8","auto");
$req = "http://persons.bayashi.net/api/relate/";

$req =$req.$ref;

$article = simplexml_load_file($req);

    $star = $article->star;
    echo "<b><a href=".$star->link . ">".$star->name . "</a></b> さんの周辺データ!";
    echo "<hr>";
    echo "<ul>";
    foreach ($article->light as $light) {
        echo "<li>";
    echo "<a href=".$light->link . ">".$light->name . "</a>";
        echo "</li>";
    }
echo "</ul>";

}

?>