|
<?
$SubscriptionId = '登録ID';
foreach( $_POST as $Key => $Value ) {
$_POST[$Key] = str_replace("\\\\", "\\", $Value );
$_POST[$Key] = str_replace("\\'", "'", $_POST[$Key] );
$_POST[$Key] = str_replace("\\\"", "\"", $_POST[$Key] );
}
if ( $_POST['send'] == 'phpinfo' ) {
phpinfo();
exit();
}
if ( $_POST['send'] == 'Direct XML' ) {
DirectXML();
exit();
}
if ( $_POST['send'] == 'テキスト表示' ) {
TextXML();
exit();
}
if ( $_POST['send'] == 'タグ名指定' ) {
if ( !extension_loaded( "domxml" ) ) {
header( "Content-Type: text/html; Charset=shift_jis" );
print "domxml は使用できません";
exit();
}
$request =
"http://webservices.amazon.co.jp/onca/xml?" .
"Service=AWSECommerceService&" .
"SubscriptionId=$SubscriptionId&" .
"Operation=ItemLookup&" .
"ResponseGroup=Large&" .
"ItemId=" . $_POST['ISBN'];
$ret = file_get_contents( $request );
$ret = str_replace(
$SubscriptionId,
'MySubscriptionId',
$ret
);
$dom = domxml_open_mem ( $ret );
$nodes = $dom->get_elements_by_tagname($_POST['TAGNAME']);
$OutData = PrintNode( $nodes );
}
# **********************************************************
# 取得した XML をそのまま表示 ( text/xml )
# **********************************************************
function DirectXML() {
global $SubscriptionId;
header( "Content-Type: text/xml; Charset=utf-8" );
$request =
"http://webservices.amazon.co.jp/onca/xml?" .
"Service=AWSECommerceService&" .
"SubscriptionId=$SubscriptionId&" .
"Operation=ItemLookup&" .
"ResponseGroup=Large&" .
"ItemId=" . $_POST['ISBN'];
$ret = file_get_contents ( $request );
$ret = str_replace(
$SubscriptionId,
'MySubscriptionId',
$ret
);
print $ret;
}
# **********************************************************
# 取得した XML テキストとして表示
# **********************************************************
function TextXML() {
global $SubscriptionId;
header( "Content-Type: text/html; Charset=utf-8" );
$request =
"http://webservices.amazon.co.jp/onca/xml?" .
"Service=AWSECommerceService&" .
"SubscriptionId=$SubscriptionId&" .
"Operation=ItemLookup&" .
"ResponseGroup=Large&" .
"ItemId=" . $_POST['ISBN'];
$ret = file_get_contents ( $request );
$ret = str_replace(
$SubscriptionId,
'MySubscriptionId',
$ret
);
$ret = str_replace( ">", ">\n", $ret );
$ret = htmlentities( $ret, ENT_NOQUOTES, "utf-8" );
print "<pre>";
print $ret;
print "</pre>";
}
# **********************************************************
# ノ−ドリスト内のデータ取得
# **********************************************************
function PrintNode( $NodeArray ) {
$ret = "";
for( $i = 0; $i < count( $NodeArray ); $i++ ) {
if ( $NodeArray[$i]->has_child_nodes() ) {
$ret .= PrintNode( $NodeArray[$i]->child_nodes() );
}
else {
$nodeWork = $NodeArray[$i]->parent_node();
$ret .= $nodeWork->node_name() . "|";
$ret .= $nodeWork->node_type() . "|";
$ret .= $NodeArray[$i]->node_name() . "|";
$ret .= $NodeArray[$i]->node_type() . "|";
if ( $nodeWork->has_attributes() ) {
$AttArray = $nodeWork->attributes();
$ret .= "(";
for( $j = 0; $j < count( $AttArray ); $j++ ) {
if ( $j != 0 ) {
$ret .= "|";
}
$ret .= $AttArray[$j]->name();
$ret .= "|";
$ret .= $AttArray[$j]->value();
}
$ret .= ")";
}
$ret .= $NodeArray[$i]->get_content() . "<br>";
}
}
return $ret;
}
?>
<HTML>
<HEAD>
<META http-equiv="Content-type" content="text/html; charset=utf-8">
</HEAD>
<BODY>
<?= $OutData ?>
</BODY>
</HTML>
| |