hier mal was einfaches, das hab ich vor langem mal in einem anderen Forum gefunden...
damit werden Amazon Produkte entsprechend dem Suchbegriff angezeigt, allerdings wird nicht immer das richtig angezeig, je nachdem welchen Wort das das Script übergeben wird..
CODE <?
$associate_id = "xxxxxx"; // amazon.de ID
$number = "3"; // Anzahl Produkte (max. 10)
$emptyterm = "$wort"; // suchbegriff
$news_array = array();
if (!$keywords)
{
$keywords = $emptyterm;
}
$url = "http://xml-eu.amazon.com/onca/xml3?t=$associate_id&dev-t=D1T29HVQ5KNUMF&mode=books&type=heavy&page=1&f=xml&locale=de";
$url .= "&KeywordSearch=$keywords";
$fp = fopen("$url","r");
while (!feof($fp))
{
if (!$fp)
{
break;
}
$linie = fgets($fp, 1024);
if(eregi("<?xml", $linie))
{
while (!feof($fp))
{
$linie = fgets($fp, 1024);
$text .= $linie;
if(ereg("</ProductInfo>", $linie)) break;
}
}
}
fclose($fp);
$text = str_replace("</Details>","#S#E#P#E#R#A#T#O#R#",$text); //Seperiert die einzelnen News
$text = explode("#S#E#P#E#R#A#T#O#R#",$text);
$TotalResults = explode("<TotalResults>", $text[0]);
$TotalResults = explode("</TotalResults>", $TotalResults[1]);
$TotalResults = $TotalResults[0];
$TotalPages = explode("<TotalPages>", $text[0]);
$TotalPages = explode("</TotalPages>", $TotalPages[1]);
$TotalPages = $TotalPages[0];
$anzahl = count($text);
for($a=0;$a<$anzahl;$a++)
{
$ProductName = explode("<ProductName>", $text[$a]);
$ProductName = explode("</ProductName>", $ProductName[1]);
$ProductName = utf8_decode($ProductName[0]);
$OurPrice = explode("<OurPrice>", $text[$a]);
$OurPrice = explode("</OurPrice>", $OurPrice[1]);
$OurPrice = $OurPrice[0];
$OurPrice = str_replace(".", "", $OurPrice);
$OurPrice = str_replace(",", ".", $OurPrice);
$OurPrice = str_replace("EUR", "", $OurPrice);
$OurPrice = trim($OurPrice);
$OldPrice = "";
$DeepLink = explode("<Details url=\"", $text[$a]);
$DeepLink = explode("\">", $DeepLink[1]);
$DeepLink = $DeepLink[0];
$Isbn = explode("<Isbn>", $text[$a]);
$Isbn = explode("</Isbn>", $Isbn[1]);
$Isbn = utf8_decode($Isbn[0]);
$ImageUrlSmall = explode("<ImageUrlSmall>", $text[$a]);
$ImageUrlSmall = explode("</ImageUrlSmall>", $ImageUrlSmall[1]);
$ImageUrlSmall = $ImageUrlSmall[0];
$ImageUrlMedium = explode("<ImageUrlMedium>", $text[$a]);
$ImageUrlMedium = explode("</ImageUrlMedium>", $ImageUrlMedium[1]);
$ImageUrlMedium = $ImageUrlMedium[0];
$ImageUrlLarge = explode("<ImageUrlLarge>", $text[$a]);
$ImageUrlLarge = explode("</ImageUrlLarge>", $ImageUrlLarge[1]);
$ImageUrlLarge = $ImageUrlLarge[0];
$Authors = explode("<Authors>", $text[$a]);
$Authors = explode("</Authors>", $Authors[1]);
$Authors = $Authors[0];
$t = substr_count($Authors, "<Author>");
if ($t > "1")
{
$Authors =str_replace("</Author>", ", ", $Authors);
$Authors = strip_tags($Authors);
$Authors = trim($Authors);
$Authors = substr($Authors, 0, -2);
$Authors = utf8_decode($Authors);
}
else
{
$Authors = strip_tags($Authors);
$Authors = utf8_decode($Authors);
}
if (strlen($OurPrice)> 1 && strlen($ProductName)> 1)
{
$newsitem_array = array($ProductName, $OurPrice, $OldPrice, $DeepLink, $Isbn, $ImageUrlSmall, $Authors);
array_push($news_array, $newsitem_array);
}
}
?>
<br />
<br />
<table width="100%" border="0" class="tabelle" cellspacing="4" cellpadding="3">
<tr>
<td><br />
<?
$anzahl = count($newsitem_array);
If ($anzahl <= $number)
{
$number = $anzahl;
}
for($x=0;$x<$number;$x++)
{
list($ProductName, $OurPrice, $OldPrice, $DeepLink, $Isbn, $ImageUrlSmall, $Authors) = $news_array[$x];
?>
<font size="2"> <div align=center><a href='<? echo($DeepLink); ?>' target="new"><img src='<? echo ($ImageUrlSmall); ?>' border='0' /></a></div><br />
<a href="<? echo($DeepLink) ?>" target="new">
<? echo($ProductName) ?> </a><br>
<a href="<? echo($DeepLink) ?>" target="new">
<? if ($Authors != "") { echo("von " . $Authors); } ?>
</a><br>
<? echo($OurPrice) ?> ¤ </font><br /> <br>
<?php
}
?>
</td>
</tr>
</table>
<br>