Answer the question
In order to leave comments, you need to log in
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;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question