Advertisement
Guest User

Untitled

a guest
May 4th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <pre>
  2. <?php
  3. ini_set("memory_limit", "1024M");
  4. $login = "***";
  5. $password = "***";
  6.  
  7.  $soapClientParamsCatalog = array('connection_timeout' => 300);
  8.  $soapClientCatalog = new
  9. SoapClient("https://api.treolan.ru/webservices/treolan.wsdl",
  10. $soapClientParamsCatalog);
  11.  try {
  12.  $paramCatalog = array(
  13.  'Login' => $login,
  14.  'password' => $password,
  15.  'category' => '',
  16.  'vendorid' => 0,
  17.  'keywords' => '',
  18.  'criterion' => 0,
  19.  'inArticul' => 0,
  20.  'inName' => 0,
  21.  'inMark' => 0,
  22.  'ShowNc' => 0);
  23.  $infoCatalog = $soapClientCatalog->__call("GenCatalogV2", $paramCatalog);
  24.  $arResult = ($infoCatalog['Result']);
  25.  
  26. $xmlCatalog = simplexml_load_string($arResult);
  27. $jsonCatalog  = json_encode($xmlCatalog);
  28. $xmlArrCatalog = json_decode($jsonCatalog, true);
  29.  
  30. function recarray($ar, $searchfor) {
  31.     static $result = array();
  32.  
  33.     foreach($ar as $k => $v) {
  34.     if ($k === $searchfor) $result[] = $v;
  35.         if (is_array($ar[$k]))  recarray($v, $searchfor);
  36.     }
  37.     return $result;
  38. }
  39.  
  40. $result = recarray($xmlArrCatalog, 'articul');
  41.  
  42. }
  43. catch (SoapFault $fault) {
  44.  print("Sorry, WS returned the following ERROR:
  45. ".$fault->faultcode."-".$fault->faultstring);
  46. }
  47.  
  48. $soapClientParamsProducts = array('connection_timeout' => 300);
  49. $soapClientProducts = new
  50. SoapClient("https://api.treolan.ru/webservice2008/Service.asmx?wsdl",
  51. $soapClientParamsProducts);
  52. try {
  53.    
  54.     foreach ($result as $i => $articuls) {
  55.         $paramProducts = array(
  56.         'Login' => $login,
  57.         'password' => $password,
  58.         'Articul' => $articuls);
  59.         $infoProducts = $soapClientProducts->__call("ProductInfoV2", array($paramProducts));
  60.  
  61.         $xmlProducts = simplexml_load_string($infoProducts->ProductInfoV2Result->any);
  62.         $jsonProducts  = json_encode($xmlProducts);
  63.         $xmlArrProducts = json_decode($jsonProducts, true);
  64.  
  65.         $res[] = $xmlArrProducts;
  66.     }
  67.    
  68.     print_r($res);
  69.  
  70. }
  71. catch (SoapFault $fault) {
  72. print("Sorry, WS returned the following ERROR:
  73. ".$fault->faultcode."-".$fault->faultstring);
  74. }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement