I
I
Igor Bykov2016-03-29 09:57:11
PHP
Igor Bykov, 2016-03-29 09:57:11

json parsing error?

There is a handler:

$Passw = md5($arWS['PASSW']);
foreach($arWsParts as $arPart){
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,"http://auto1.by/api/Tradesoft/?action=get_price_list&login=".$arWS['LOGIN']."&password=".$Passw."&code=".urlencode($arPart['ARTICLE'])."&producer=".urlencode($arPart['BRAND']);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $json = curl_exec($ch);
  curl_close($ch);
  $jsonRes = json_decode($json);
  //echo "http://auto1.by/api/Tradesoft/?action=get_price_list&login=".$arWS['LOGIN']."&password=".$Passw."&code=".urlencode($arPart['ARTICLE'])."&producer=".urlencode($arPart['BRAND'])
  //echo '<br><pre>'; print_r($json); echo '</pre><br><br>'; 
  if(is_array($jsonRes)){
    //echo '<pre>'; print_r($jsonRes); echo '</pre>';//die();
    foreach($jsonRes as $obRes){
      //Make valid Price array
      $arPrice = TDMPriceArray($arPart); 
      //Webservice data
      $arPrice["ARTICLE"] = (string)$obRes->code;
      $arPrice["ALT_NAME"] = (string)$obRes->caption;
      $arPrice["BRAND"] = (string)$obRes->produсer;
      $arPrice["PRICE"] = (string)$obRes->price;
      $arPrice["CURRENCY"] = $arWS['CURRENCY'];
      $arPrice["DAY"] = (string)$obRes->delivery;
      $arPrice["AVAILABLE"] = (string)$obRes->rest;
      $arPrice["OPTIONS"] = '';
      //Price options
      $arOps = Array();
      $MINIMUM = (string)$obRes->minquantity;
      if($MINIMUM>1){$arOps['MINIMUM']=$MINIMUM;}
      $arPrice["OPTIONS"] = TDMOptionsImplode($arOps,$arPrice);
      //Add new record
      $arPrices[] = $arPrice;
    }
  }elseif(is_object($jsonRes)){
    if($jsonRes->errorCode>0){
      if($jsonRes->errorCode==301){continue;} //No results
      $ERROR = $jsonRes->errorMessage.' ['.$jsonRes->errorCode.']';
      break;
    }
  }
  
}

starts working correctly, gets all prices and links, but when requesting a price, it gives an error:
Parse error: syntax error, unexpected ';' in /home/poehalib/public_html/autoparts/tdmcore/webservices/auto1.by.php on line 37
37 line - curl_setopt($ch, CURLOPT_URL," auto1.by/api/Tradesoft/?action=get_price_list&login= ".$arWS ['LOGIN']."&password=".$Passw."&code=".urlencode($arPart['ARTICLE'])."&producer=".urlencode($arPart['BRAND']);
what is wrong? Help...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question