I am trying to build a php system which will send transactions to
a server on a financial firm (receiver). The firm will then return
status of done transactions to me.
I have been told to do this in php from the firm and have got some
coding-examples. My problem is to do the coding in php since i don't have
much experience in php.
As i see it i have to build a loop which sends data every 10 second,
read the answers from the firm.
The code i have managed to build so far and which doesn't work:
Can someone help me to get the code working?
I have exluded correct ip-address due to restrictions from the firm:
Code: Select all
<?php
$fp = fsockopen("tcp://xx.xx.xx.xx", xxxx, $errno, $errstr);
if (!$fp) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
$szData = '<?xml version="1.0" encoding="Windows-1252" ?>
<Signal xmlns="http://b.se/TESSignal.xsd">
<Version>1.0</Version>
<SignalType>Entry</SignalType>
<PositionType>Long</PositionType>
<Instrument>OMXS30-8LT</Instrument>
<Strategy>RankorTest</Strategy> <Price>889</Price>
<Weight>1</Weight>
<Comment>RankorTest</Comment>
</Signal>';
fwrite($fp, $szData);
print $szData;
print("XML-sträng skickad ");
// Skickar frågor på port xxxx.
$fp2 = fsockopen("tcp://xx.xx.xx.xx", xxxx, $errno, $errstr);
$szData2 = 'info;RankorTest';
fwrite($fp2, $szData2 );
print $szData2;
print("Fråge-sträng skickad på port xxxx");
// $buffer hamnar allt som mottagits ifrån servern
// $fp innehåller din fsockopen connection
while(true)
{
$str = fread($fp2, 1);
$buffer .= $str;
print $buffer;
if($str == "\n")
{
break;
}
}
// fwrite($fp, "\n");
// echo fread($fp, 26);
fclose($fp);
}
?>