当前位置: 首页>>代码示例>>PHP>>正文


PHP soapclient::ItemLookup方法代码示例

本文整理汇总了PHP中soapclient::ItemLookup方法的典型用法代码示例。如果您正苦于以下问题:PHP soapclient::ItemLookup方法的具体用法?PHP soapclient::ItemLookup怎么用?PHP soapclient::ItemLookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在soapclient的用法示例。


在下文中一共展示了soapclient::ItemLookup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fetchAmazonInfos

 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!";
     }
//.........这里部分代码省略.........
开发者ID:rdegennaro,项目名称:Check-It,代码行数:101,代码来源:admin.booklibrary.class.ws.php


注:本文中的soapclient::ItemLookup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。