function fetchAmazonInfos($book) { global $booklibrary_configuration, $my, $acl; //****************************** Added by OrdaSoft ********************************** $param_ws = mosBooklibraryWS::getWsParamById($book->informationFrom); $Timestamp = date("Y-m-d") . "T" . date("H:i:s") . "Z"; //if amazon.com if ($param_ws == "COM" || $param_ws == "UK" || $param_ws == "CA") { try { if ($param_ws == "UK" || $param_ws == "CA") { $client = new soapclient("https://webservices.amazon.com/AWSECommerceService/" . $param_ws . "/AWSECommerceService.wsdl", array('proxy_host' => $booklibrary_configuration['proxy_server']['address'], 'proxy_port' => $booklibrary_configuration['port_proxy_server']['address'], 'proxy_login' => $booklibrary_configuration['login_proxy_server']['address'], 'proxy_password' => $booklibrary_configuration['password_proxy_server']['address'])); } else { if ($param_ws == "COM") { $client = new soapclient("https://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl", array('proxy_host' => $booklibrary_configuration['proxy_server']['address'], 'proxy_port' => $booklibrary_configuration['port_proxy_server']['address'], 'proxy_login' => $booklibrary_configuration['login_proxy_server']['address'], 'proxy_password' => $booklibrary_configuration['password_proxy_server']['address'])); } } $client->xml_encoding = "UTF-8"; $params = array('Request' => array('SearchIndex' => 'Books', 'IdType' => 'ISBN', 'ItemId' => $book->isbn, 'ResponseGroup' => 'Large'), 'AWSAccessKeyId' => $booklibrary_configuration['ws']['amazon']['devtag'], 'AssociateTag' => $booklibrary_configuration['ws']['amazon']['tag'], 'Timestamp' => $Timestamp, 'Signature' => "ItemLookup" . $Timestamp); $result = $client->ItemLookup($params); } catch (SoapFault $fault) { $retVal = "SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})"; return $retVal; // trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); } } else { try { $client = new soapclient("https://webservices.amazon.com/AWSECommerceService/" . $param_ws . "/AWSECommerceService.wsdl", array('proxy_host' => $booklibrary_configuration['proxy_server']['address'], 'proxy_port' => $booklibrary_configuration['port_proxy_server']['address'], 'proxy_login' => $booklibrary_configuration['login_proxy_server']['address'], 'proxy_password' => $booklibrary_configuration['password_proxy_server']['address'])); $client->xml_encoding = "UTF-8"; $params = array('Request' => array('IdType' => 'ASIN', 'ItemId' => $book->isbn, 'ResponseGroup' => 'Large'), 'AWSAccessKeyId' => $booklibrary_configuration['ws']['amazon']['devtag'], 'AssociateTag' => $booklibrary_configuration['ws']['amazon']['tag'], 'Timestamp' => $Timestamp, 'Signature' => "ItemLookup" . $Timestamp); $result = $client->ItemLookup($params); } catch (SoapFault $fault) { $retVal = "SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})"; return $retVal; // trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); } } //Errors test -- 1 if (array_key_exists('Errors', $result->OperationRequest)) { $retVal = "SOAP Fault: (faultcode: {$result->OperationRequest->Errors->Error->Code}, faultstring: {$result->OperationRequest->Errors->Error->Message})"; return $retVal; } //Errors test -- 2 if (array_key_exists('Errors', $result->Items->Request)) { $retVal = "SOAP Fault: (faultcode: {$result->Items->Request->Errors->Error->Code}, faultstring: {$result->Items->Request->Errors->Error->Message})"; return $retVal; } //Body -- Output in joomla form //ProductName $book->title = $result->Items->Item->ItemAttributes->Title; //ImageUrlMedium $book->imageURL = $result->Items->Item->MediumImage->URL; //URL $book->URL = $result->Items->Item->DetailPageURL; //Manufacturer if (array_key_exists('Manufacturer', $result->Items->Item->ItemAttributes)) { $book->manufacturer = $result->Items->Item->ItemAttributes->Manufacturer; } //Author $book->authors = ""; if (is_array($result->Items->Item->ItemAttributes->Author)) { //Authors array foreach ($result->Items->Item->ItemAttributes->Author as $Author) { if (strlen($book->authors) > 0) { $book->authors = $book->authors . ", " . $Author; } else { $book->authors = $Author; } } } else { $book->authors = $result->Items->Item->ItemAttributes->Author; //Authors not array } //Rating if (array_key_exists('CustomerReviews', $result->Items->Item)) { $book->rating = $result->Items->Item->CustomerReviews->AverageRating * 2; } //PublicationDate if (array_key_exists('PublicationDate', $result->Items->Item->ItemAttributes)) { $book->release_Date = $result->Items->Item->ItemAttributes->PublicationDate; } //ReleaseDate if (array_key_exists('ReleaseDate', $result->Items->Item->ItemAttributes)) { $book->release_Date = $result->Items->Item->ItemAttributes->ReleaseDate; } //Edition if (array_key_exists('Edition', $result->Items->Item->ItemAttributes)) { $book->edition = $result->Items->Item->ItemAttributes->Edition; } //Price no partner if (array_key_exists('Offer', $result->Items->Item->Offers) && array_key_exists('FormattedPrice', $result->Items->Item->Offers->Offer->OfferListing->Price)) { $book->price = $result->Items->Item->Offers->Offer->OfferListing->Price->FormattedPrice; $mas = $book->price; $mas = ereg_replace("£", "GBP ", $mas); //for funt $mas = ereg_replace("¥", "JPY", $mas); //for ena $book->price = $mas; } else { $book->price = "Does not exist anymore!"; } //************************ begin add for Book Description ********************* if ($booklibrary_configuration['merge_description']['use']) { if (checkAccessBL($booklibrary_configuration['merge_description']['registrationlevel'], 'RECURSE', userGID_BL($my->id), $acl)) { $book->comment = $book->comment . "<br /><p></p> "; } else { $book->comment = ""; } } else { $book->comment = ""; } if (array_key_exists('EditorialReviews', $result->Items->Item) && array_key_exists('EditorialReview', $result->Items->Item->EditorialReviews)) { if (count($result->Items->Item->EditorialReviews->EditorialReview) == 1) { $book->comment .= "<strong>" . $result->Items->Item->EditorialReviews->EditorialReview->Source . "</strong><br />"; $book->comment .= $result->Items->Item->EditorialReviews->EditorialReview->Content; } else { if (count($result->Items->Item->EditorialReviews->EditorialReview) >= 1) { for ($i = 0; $i < count($result->Items->Item->EditorialReviews->EditorialReview); $i++) { $book->comment .= "<strong>" . $result->Items->Item->EditorialReviews->EditorialReview[$i]->Source . "</strong><br />"; $book->comment .= $result->Items->Item->EditorialReviews->EditorialReview[$i]->Content . "<br />"; } //end for } } //end if } //************************ end add for Book Description ************************ return $book; }