Created
November 6, 2009 00:54
-
-
Save eight/227571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//XML-RPC yubin.class.php 使用サンプル | |
if (isset($_GET['show_source'])) { | |
highlight_file('sample.php'); | |
exit; | |
} | |
?> | |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
<html> | |
<head> | |
<title>XML-RPC yubin.class.php 使用サンプル - 郵便専門ネット</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp"> | |
</head> | |
<body> | |
<a href="http://yubin.senmon.net/service/xmlrpc.html">XML-RPCを使うへ戻る</a><br> | |
<h1>XML-RPC yubin.class.php 使用サンプル</h1> | |
<p>郵便番号を入力して送信ボタンをクリックしてください。</p> | |
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="get"> | |
郵便番号 <input type="text" size="10" name="postcode" value="<?php echo $_GET['postcode']; ?>"><br> | |
<input type="submit" value="XML-RPCリクエストを送信"> | |
</form> | |
<?php | |
include_once('yubin.class.php'); | |
$debug=isset($_GET['debug']) ? $_GET['debug'] : false; | |
$rpc = new YubinXMLRPC_Client($debug); | |
//バージョンの取得 | |
$result = $rpc->GetVersion(); | |
if ($result) echo "<h2>GetVersion 全国郵便番号一覧 ver. $result</h2>"; | |
else { | |
echo sprintf('GetVersion error. %s %s',$rpc->error_code,$rpc->error_string); | |
} | |
//住所の取得 | |
echo "<h2>FetchAddress</h2>"; | |
$result = $rpc->FetchAddress($_GET['postcode'],'EUC-JP'); | |
$_GET['data_type'] = ""; | |
if ($result) { | |
echo "郵便番号 '" .$_GET['postcode'] . "'が見つかりました。" . count($result) . "件ありました。"; | |
echo "<table>"; | |
foreach($result AS $addr) { | |
echo $addr->AsHTML(false); | |
} | |
echo "</table>"; | |
} else { | |
if ($rpc->error_code) { | |
echo "呼び出しエラー発生: " .$rpc->error_code .":". $rpc->error_string; | |
} else echo "郵便番号 '" .$_GET['postcode'] . "'は見つかりませんでした。"; | |
} | |
?> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment