Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/123421-api-geting-wrong-data/
Share on other sites

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

 

 

 

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++;
}
}

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.