User Tools

Site Tools

  • en

Sample Code (PHP)

Login into Webstore system (PHP)

function do_https($url, $postfields) {
$login = "";
$pass = "";
$ch = curl_init($url);
 
// авторизация
// login
 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $login . ':' . $pass);
 
// на тесте необходимо отключить проверку подлинности сертификата "SSL certificate problem, verify that the CA cert is OK"
// during the test, disable certificate authenticity verification 'SSL certificate problem, verify that the CA cert is OK'
 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
 
// результат вернуть в переменную
// return result in variable
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ($postfields)
{
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/xml; charset=utf-8", "Content-Length:" . strlen($postfields)));
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
}
$xmlString = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$xml = simplexml_load_string($xmlString);
curl_close($ch);
return $xml;
}

Placement of simple order (PHP)

$orderXML = new SimpleXMLElement($orderXMLString);
 
$orderXML->OrderNum = 'MyUnicumOrderNumber-1234567890';
 
$orderXML->PartNum = 'T5D-00432';
 
$orderXML->quantity = 1;
 
$postString = $orderXML->asXML();
 
$returnOrder = do_https("https://sandbox.webstore.mont.ru/B2BService.svc/web/AddOrder", $postString);

Obtaining result of order fulfilment (PHP)

 
$orderXML = new SimpleXMLElement($orderXMLString);
 
$orderXML->OrderNum = 'MyUnicumOrderNumber-1234567890';
 
$postString = $orderXML->asXML();
 
$returnOrder = do_https("https://sandbox.webstore.mont.ru/B2BService.svc/web/GetOrder", $postString);