alin19 Posted September 9, 2008 Share Posted September 9, 2008 those are the lines that i'm geting with java: <usage t='222'> <first><number>503</number><value>ALIN</value></first> <first><number>504</number><value>ROMANIA</value></first> <first><number>620</number><value>FOCSANI</value></first> <first><number>630</number><value>3.1</value></first> <first><number>510</number><value>0.05</value></first> <first><number>511</number><value>0.0</value></first> <first><number>635</number><value>0.16</value></first> <first><number>520</number><value>0.0</value></first> <first><number>530</number><value>0.0</value></first> <first><number>531</number><value>0.0</value></first> <first><number>525</number><value>0</value></first> <first><number>540</number><value>0</value></first> <first><number>542</number><value>0</value></first> <first><number>550</number><value>100</value></first> </usage> and those are the line that i'm geting with php 0---------¯(here are some signs , in cmd looks like happy faces, something like those from messenger) <usage t='112'> <first><number>503</number><value>ALIN</value></first> <first><number>504</number><value>ROMANIA</value></first> <first><number>510</number><value>FOCSANI</value></first> <first><number>511</number><value>0</value></first> <first><number>525</number><value>0</value></first> <first><number>505</number><value>10.96</value></first> <first><number>520</number><value>0</value></first> <first><number>530</number><value>0</value></first> <first><number>531</number><value>0.0</value></first> <first><number>500</number><value>Active</value></first> <first><number>540</number><value>0</value></first> <first><number>550</number><value>0</value></first> <first><number>542</number><value>0</value></first> </usage> i java i think data are decoded with readUTF, how can i do that in php? Quote Link to comment https://forums.phpfreaks.com/topic/123421-api-geting-wrong-data/ Share on other sites More sharing options...
Zane Posted September 9, 2008 Share Posted September 9, 2008 well first of all....what are you doing? obviously either PHP or Java have received a different variable at some point or different input of some kind. to get different values like that Excluding that fact that you want it to have the same values as Java or vice versa, what are you wanting it to do....where's the code that's an odd looking smiley Quote Link to comment https://forums.phpfreaks.com/topic/123421-api-geting-wrong-data/#findComment-637415 Share on other sites More sharing options...
alin19 Posted September 9, 2008 Author Share Posted September 9, 2008 here is the code with what i'm trying to get those data, i've added some line to get rid of those things, but i still get some error, the values are diferent because there are not the same lines, while (true) { if (false === ($line = socket_read($sock, 2048))) echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($msgsock)) . "\n"; else if ($line!="<st t='line'>error</st>\n") { $start=strpos ($line,"<usage t"); $end=strpos ($line,"</usage>",$start); $x=substr($line,2,$end+6); $xml="<?xml version='1.0'?>".$x; if (false==$xmlL = simplexml_load_string($xml)) fwrite($handleError,$i."++++".$xml."\n"); foreach ($xmlL->first as $info) echo $info->number." ".$info->value."\n"; echo "--------------------------------------------------"; if (fwrite($handle, $i."---------".$line) === FALSE) { echo "Cannot write to file ($filename)"; exit; } unset ($xml); unset ($line); $i++; } } Quote Link to comment https://forums.phpfreaks.com/topic/123421-api-geting-wrong-data/#findComment-637424 Share on other sites More sharing options...
alin19 Posted September 9, 2008 Author Share Posted September 9, 2008 as you see there when i get an error, it will be outputed in a file, those are the lines from the error file: if the front 5-6-7 is $i, then some ++++, that i've added and then the xml message, but sometimes is wrong 5++++<?xml version='1.0'?><usage t='112'> <first><number>503</number><value>ION</value></first> <first><number>504</number><value>APR08</value></first> <first><number>510</number><value>0</value></first> <first><number>511</number><value>0</value></first> <first><number>525</number><value>0</value></first> <first><number>505</number><value>1.21</value></first> <first><number>520</number><value>0</value></first> <first><number>530</number><value>0</value></first> <first><number>531</number><value>0.0</value></first> <first><number>500</number><value>Active</value></first> <first><number>540</number><value>0</value></first> <first><number>550</number><value>0</value></first> <first><number>542</number><value>0</value></first> </usage> <usage t='11 6++++<?xml version='1.0'?><usage t='112'> <first><number>503</number><value>GHEORGHE</value></first> <first><number>504</number><value>IUN08</value></first> <first><number>510</number><value>0</value></first> <first><number>511</number><value>0</value></first> <first><number>525</number><value>0</value></first> <first><number>505</number><value>1.73</value></first> <first><number>520</number><value>0</value></first> <first><number>530</number><value>0</value></first> <first><number>531</number><value>0.0</value></first> <first><number>500</number><value>Active</value></first> <first><number>540</number><value>0</value></first> <first><number>550</number><value>0</value></first> <first><number>542</number><value>0</value></first> </usage> <usage t='112'> <first><la 7++++<?xml version='1.0'?>42</number><value>0</value></first> </usage Quote Link to comment https://forums.phpfreaks.com/topic/123421-api-geting-wrong-data/#findComment-637428 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.