Hello all, When I set the "ItemPage" parameter in my code to pages certain pages, I am getting the error, " Notice : Trying to get property of non-object in C:\wamp\www\trythis4.php on line 91 ". When I set the "ItemPage" attribute to other pages, I don't get any notices. I don't understand why I am getting Notices on some pages and not others. Can anyone shed some light on this? In my non-scientific test, pages 3, 6,11,12,67, and perhaps others are returning "Notices" when I run the code. Other pages, 1,2,4,5,7-10 seem to work ok. here is my code: <?php class Amazon { // public key var $publicKey = ""; // private key var $privateKey = ""; // affiliate tag var $affiliateTag='affiliateTag'; /** *Get a signed URL *@param string $region used to define country *@param array $param used to build url *@return array $signature returns the signed string and its components */ public function generateSignature($param) { // url basics $signature['method']='GET'; $signature['host']='ecs.amazonaws.'.$param['region']; $signature['uri']='/onca/xml'; // necessary parameters $param['Service'] = "AWSECommerceService"; $param['AWSAccessKeyId'] = $this->publicKey; $param['Timestamp'] = gmdate("Y-m-d\TH:i:s\Z"); $param['Version'] = '2009-10-01'; ksort($param); foreach ($param as $key=>$value) { $key = str_replace("%7E", "~", rawurlencode($key)); $value = str_replace("%7E", "~", rawurlencode($value)); $queryParamsUrl[] = $key."=".$value; } // glue all the "params=value"'s with an ampersand $signature['queryUrl']= implode("&", $queryParamsUrl); // we'll use this string to make the signature $StringToSign = $signature['method']."\n".$signature['host']."\n".$signature['uri']."\n".$signature['queryUrl']; // make signature $signature['string'] = str_replace("%7E", "~", rawurlencode( base64_encode( hash_hmac("sha256",$StringToSign,$this->privateKey,True ) ) ) ); return $signature; } /** * Get signed url response * @param string $region * @param array $params * @return string $signedUrl a query url with signature */ public function getSignedUrl($params) { $signature=$this->generateSignature($params); return $signedUrl= " http://".$signature['host'].$signature['uri'].'?'.$signature['queryUrl'].'&Signature='.$signature['string']; } } ?> <?php $Amazon=new Amazon(); $parameters=array( "region"=>"com", "AssociateTag"=>'affiliateTag', 'ResponseGroup'=>'Images', "Operation"=>"ItemSearch", "SearchIndex"=>"Books", "ItemPage"=>30, "Keywords"=>"biology of the cell" ); $queryUrl=$Amazon->getSignedUrl($parameters); echo $queryUrl; echo '<br/> <a href="'.$queryUrl.'">XML</a><p>'; $XML = simplexml_load_file($queryUrl); //print_r ($XML); $i=0; do { $Book_Image = $XML->Items->Item[$i++]->ImageSets->ImageSet->MediumImage->URL[0]; print '<img src="'. $Book_Image .'" />'; } while ($i<=4); $Price = $XML->Items->Item->OfferSummary->LowestNewPrice //$Price = $XML->Items->Item->OfferSummary->LowestNewPrice->FormattedPrice[0]; //echo $Price; ?>
line 91 is $Book_Image = $XML->Items->Item[$i++]->ImageSets->ImageSet->MediumImage->URL[0]; this notice means that there is no such an object you are trying to access. According to your code and common sense it looks like there is no image for that book (or no medium image or no book at all)