PDA

View Full Version : AWS Author?



incka
04-04-2004, 07:04 AM
What is the thing for Author, I can't get any Authors to display using:

<b>Written by:</b> <? echo $items[0]['Author']; ?>

GCT13
04-04-2004, 08:34 AM
If you're using something similar to my tutorial, you would set the variable as an array (because there could be more than I author)-
elseif($d_ar[$j]['tag'] == 'Author')
{$Author[] = $d_ar[$j]['value'];}
And then display the authors as such-

foreach($Author as $auth){
echo $auth. ' ';
}

incka
04-04-2004, 08:49 AM
I have absolutly no idea how to implement what you just said.

This is my code:


<?php

require_once('/home/nichetim/public_html/jewelrystore/jpcache/jpcache.php');

// include class
include("nusoap.php");

// create a instance of the SOAP client object
$soapclient = new
soapclient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl",
true);

// uncomment the next line to see debug messages
// $soapclient->debug_flag = 1;

$var_array = explode("/",$REQUEST_URI);

$var = $var_array[2];
$asin = $var;

// create a proxy so that WSDL methods can be accessed directly
$proxy = $soapclient->getProxy();

// set up an array containing input parameters to be
// passed to the remote procedure
$params = array(
'asin' => $asin,
'tag' => 'games2go-20',
'type' => 'heavy',
'devtag' => 'D2B58IDSY7XE6F'
);

// invoke the method
$result = $proxy->ASINSearchRequest($params);
$items = $result['Details'];
?>
<title>Book Reviews - <? echo $items[0]['ProductName']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style1 {
font-family: Tahoma;
font-size: xx-small;
}
.style2 {
font-family: Tahoma;
font-size: xx-small;
font-weight: bold;
color: #947d36;
}
.style3 {font-size: xx-small; color: #947d36; font-family: Tahoma;}
.style4 {color: #5a4916}
.style5 {font-family: Tahoma; font-size: xx-small; color: #5a4916; }
.style6 {
color: #FF6600;
font-weight: bold;
}
.menu {
text-decoration: none;
color: #947d36;
font-family: "Verdana";
font-size: xx-small;
font-weight: bold;
width: 160px;
position: static;
padding-left: 2px;
display: block;
}
a.menu:hover {
text-decoration: none;
color: #947d36;
font-family: "Verdana";
font-size: xx-small;
font-weight: bold;
background-color: #BFB69D;
width: 160px;
position: static;
padding-left: 2px;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF" link="#FF6600" vlink="#FF6600" alink="#FF6600">
<form action="http://www.book-reviews.ws/search.php" method="get">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="239"><table width="239" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="69"><img src="http://www.book-reviews.ws/images/index_13.gif" width="69" height="25"></td>
<td background="http://www.book-reviews.ws/images/index_14.gif"><div align="center">
<input type="text" size="20" name="q">
</div></td>
<td width="42"><input type="image" src="http://www.book-reviews.ws/images/index_15.gif" width="42" height="25" border="0"></td>
</tr>
</table></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="http://www.book-reviews.ws/images/index_16.gif"><img src="http://www.book-reviews.ws/images/spacer.gif" width="1" height="16"></td>
</tr>
<tr>
<td><table width="379" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="345" background="http://www.book-reviews.ws/images/spacer.gif" bgcolor="white"><img src="http://www.book-reviews.ws/images/spacer.gif" width="379" height="9"></td>
</tr>
</table></td>
</tr>
</table></td>
<td height="25" background="http://www.book-reviews.ws/images/bg_stretch.gif"><img src="http://www.book-reviews.ws/images/spacer.gif" width="95" height="25"></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="187"><img src="http://www.book-reviews.ws/images/title_into.gif" width="187" height="23" alt="Book Reviews Categories" /></td>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="white"></td>
<td width="39"></td>
</tr>
</table></td>
<td width="152" bgcolor="BFB69D"><img src="http://www.book-reviews.ws/images/title_bestseller.gif" width="90" height="17"></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="171" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="http://www.book-reviews.ws/images/side_curve.gif" width="171" height="10"></td>
</tr>
<tr>
<td valign="top" background="http://www.book-reviews.ws/images/side_bg.gif"><table width="93%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td height="100%">

<?php include("left.inc"); ?>

<p class="style2"></p>
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />

</td>
</tr>
</table></td>
</tr>

</table></td>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22" background="http://www.book-reviews.ws/images/content_side_bgleft.gif">&nbsp;</td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><center><font class="style2 style4"><a href="http://www.book-reviews.ws" title="Book Reviews" style="text-decoration:none;" class="style2 style4"><h1>Book Reviews</h1></a></font></center><strong class="style2 style4"><font size="2" face="Georgia, Times New Roman, Times, serif"><? echo
$items[0]['ProductName']; ?> </font></strong></td>
</tr>
<tr>
<td height="16"><div align="left"><img src="http://www.book-reviews.ws/images/separator.gif" width="398" height="12"></div></td>
</tr>
<tr>
<td class="style5"><font size="1">
</form>



<table>
<tr>
<td width="160"><div align="center">
<img border=0 bordercolor=#336699 src="
<? echo
$items[0]['ImageUrlMedium']; ?>
"></div></td>
<td>
<table width=65% border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=60%>
<b>Book:</b> <? echo
$items[0]['ProductName']; ?><br>
<b>Written by:</b> <? echo
$items[0]['Author']; ?>

</td>
</tr><tr>
<td width="60%">
<b>Publisher:</b> <? echo $items[0]['Manufacturer']; ?><br>
<? if (count($items[0]['Reviews']['AvgCustomerRating']) != 0) { ?>
<b>Average Customer Rating:</b> <? echo $items[0]['Reviews']['AvgCustomerRating']; ?> / 5
<? }
else {
echo "<b>Average Rating:</b> No Rating Available";
} ?>
<br>
<form method="POST" action="http://www.amazon.com/exec/obidos/dt/assoc/handle-buy-box=<? echo $asin; ?>">
<input type="hidden" name="asin.<? echo $asin; ?>" value="1">
<input type="hidden" name="tag-value" value="games2go-20">
<input type="hidden" name="tag_value" value="games2go-20">
<input type="hidden" name="dev-tag-value" value="D6Y8R22P5D1FJ">
<input type="submit" name="submit.add-to-cart" value="Buy From Amazon.com">
</form>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table width=95% border=0 cellspacing=0 cellpadding=0>
<tr><td class="productinfo" width="80%"> <?
if (count($items[0]['Reviews']['CustomerReviews']) != 0) {
foreach($items[0]['Reviews']['CustomerReviews'] as $r)
{

?>

<b><? echo $r['Summary']; ?>
<br>Rating: <i>
<? echo $r['Rating']; ?> / 5
<br></i></b>
<? echo $r['Comment']; ?>
<hr color=#336699 size=0 align="center"><br><br>
<?
}
}
else {
echo "No reviews currently available.";
}
?>
</td>
</tr>
</table>

</font></td>

GCT13
04-04-2004, 09:14 AM
Try this-
if (count($items[0]['Authors']) != 0){
foreach($items[0]['Authors'] as $auth){
echo $auth['Author']. ' ';
}
}Understand how I derived this? It helps to look at the XML to see how the tags are nested. What you have here is 1 or more <Author> tags nested within the <Authors> tag. It's similar to how you display the customer reviews.

incka
04-04-2004, 09:15 AM
I'm not sure how to implement it, thats my problem...

incka
04-04-2004, 10:02 AM
I can't get it to work...

GCT13
04-04-2004, 10:08 AM
I edited the code, found an error. Try it now.

incka
04-04-2004, 10:12 AM
I'm getting this:

Written by:
Warning: Invalid argument supplied for foreach() in /usr/home/nichetim/public_html/bookreviews/book-reviews on line 261

GCT13
04-04-2004, 10:14 AM
Okay, found another error and edited the post. Please try again...

incka
04-04-2004, 10:17 AM
http://www.book-reviews.ws/book-reviews/0060977337

Look, it's is displaying the initial now...

incka
04-04-2004, 10:33 AM
Just a time check

GCT13
04-04-2004, 10:16 PM
Kinda strange how it's displaying only the very first character of the author. Hmmm. (It's tricky using this AWS technique without being able to test it myselft so please bear with me.) Try this-
if (count($items[0]['Authors']['Author']) != 0){
echo '<strong>Written by:</strong> ';
foreach($items[0]['Authors']['Author'] as $auth){
echo $auth. ' ';
}
}

incka
04-05-2004, 02:17 AM
Now it doesn't display anything :(

Do I need to put something in the head part of the document?

GCT13
04-06-2004, 07:38 AM
Try this-
<?php
echo 'Written by: ' .$items[0]['Authors']['Author']. '<br /><br />';
?>

incka
04-06-2004, 09:01 AM
Not working :(

Do you have MSN? I can give you FTP account and a reward (.com or .info or hosting on my server) if you get it fixed...

GCT13
04-06-2004, 12:56 PM
I'd prefer the .com top level domain registry. I'll see what I can do.

incka
04-06-2004, 02:37 PM
I'll only buy while godaddy is having the sale.

GCT13
04-11-2004, 11:07 AM
At last, this is proven to work:
if(count($items[0]['Authors']) != 0){
echo '<b>Written by:</b> ';
foreach($items[0]['Authors'] as $auth){
echo $auth. ' ';
}
}