Send two txt fields via soap using PHP

0

I need to get the values of two fields from a file in .txt and send via Soap .

Soap is already working, when I enter the Barcode and absoluteQuantity it sends the correct value, but now I need to make this field be fed by the file of .txt , see image below.

<?php    
    $client = new SoapClient('http://rcs01-sales.fftech.info/pub/apistock.asmx?wsdl');
    $function = 'BarcodeProcessAbsoluteQuantity';
    $arguments= array('BarcodeProcessAbsoluteQuantity' => array(
                        'Key'   => '5VWyXKYZxH0=',
                        'Barcode'                 => 8054182140865,
                        'absoluteQuantity'        => 2,
                        'ErrMsg'      => '0',
                        'IsAdjustment'      => '0',
                        'currentStock'      => '0',
                ));

    $options = array('location' => 'http://rcs01-sales.fftech.info/pub/apistock.asmx?wsdl');
    $result = $client->__soapCall($function, $arguments, $options);

    echo 'RESPOSTA:';
    print_r($result);
?>
    
asked by anonymous 14.09.2017 / 20:14

1 answer

1

Just read the contents of the file using file_get_contents and go through the lines by breaking \n and also ; .

$txtContent = "1;1\n2;2\n3;3"; // file_get_contents('file.txt');

$arrayContent = explode("\n", $txtContent);

foreach ($arrayContent as $string) {
    list($barcode, $absoluteQuantity) = explode(';', $string);

    echo "Bardcode {$barcode} with {$absoluteQuantity} quantity\n";
}

Live: link

    
15.09.2017 / 15:48