Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding Issue in get_all_user_info #9

Closed
ahmedali5530 opened this issue Dec 14, 2015 · 9 comments
Closed

Encoding Issue in get_all_user_info #9

ahmedali5530 opened this issue Dec 14, 2015 · 9 comments

Comments

@ahmedali5530
Copy link

Hi @cobisja,
i m using this library for fetching user information from machine but error occurs while triggering the get_all_user_info function, the error message is here

Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xFB 0x86 0x3C 0x2F in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php on line 462

Warning: SimpleXMLElement::__construct(): 1><TZ2>0</TZ2><TZ3>0</TZ3></Row><Row><PIN>12</PIN><Name>20-weweweweee kkkiiikiik in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php on line 462

Warning: SimpleXMLElement::__construct(): ^ in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php on line 462

Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : PCDATA invalid Char value 1 in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php on line 462

Warning: SimpleXMLElement::__construct(): ><TZ2>0</TZ2><TZ3>0</TZ3></Row><Row><PIN>14</PIN><Name>21-weweweweee kkkiiikiik2 in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php on line 462

Warning: SimpleXMLElement::__construct(): ^ in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php on line 462

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php:462 Stack trace: #0 C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php(462): SimpleXMLElement->__construct('<GetAllUserInfo...') #1 C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php(446): TADResponse->get_items_number('<GetAllUserInfo...') #2 C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php(95): TADResponse->is_there_no_data('<GetAllUserInfo...') #3 C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php(70): TADResponse->set_response('<GetAllUserInfo...') #4 C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\Providers\TADSoap.php(108): TADResponse->__construct('<?xml version="...', 'iso8859-1') #5 C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TAD.php(290): TADSoap->execute_soap_command('get_all_user_in...', Array, 'iso8859-1') #6 C:\Program Files in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php on line 462

Any ideas how to resolve this issue.

@cobisja
Copy link
Owner

cobisja commented Dec 14, 2015

3 questions : 1) Your data have special characters like Chinese, Arabic or something like that?. 2) did you use the parameter "encoding" when you get a TAD-PHP instance?. 3) can you send me the sample code you used?

@ahmedali5530
Copy link
Author

  • I use simple Alphabetical characters while adding data into machine.
  • I use this code while getting the instance of tad
$tad = (new TADFactory(['ip'=>'machine ip', 'com_key'=>0]))->get_instance();
  • And use this for getting the user information from machine
$all_user_info = $tad->get_all_user_info()->to_array();

@cobisja
Copy link
Owner

cobisja commented Dec 16, 2015

My friend, it seems the XML response received from your device is invalid in someway. To be sure please copy, paste and run, as an alone script, the following PHP code and send to me the response generated:

<?php
$your_ip = 'xxx.xxx.xx.xx'; // Set here your device's ip

$options = array(
    'location' => 'http://' . $your_ip . '/iWsService',
    'uri' => 'http://www.zksoftware/Service/message/'
);

$client = new SoapClient(null, $options);
$soapRequest = "<GetAllUserInfo><ArgComKey>0</ArgComKey></GetAllUserInfo>";

$response = $client->__doRequest($soapRequest, 'http://' . $your_ip . '/iWsService', '', '1.1');

echo '<pre>', var_dump($response), '</pre>'; // Please copy the whole string generated here and send it to me

I hope I can find out where the problem is. It is a little complicated to help you because I don't have a device where I can run some tests.

@ahmedali5530
Copy link
Author

Here is the response which i get from machine according to your instructions

string(3342) "

110-Fatima Zaheer123450022221401060000
214-Hira Iqbal123450022299811429000
313-Momina Chaudhry123450032042511362000
416-Hashim Iqbal1234511482932321656000
512-Kashif Ali123450032210261253000
69-Zaheer Saeed12345003186861938000
717-Aurangzaib Nawaz123450022419471771000
818-Ali Mian123450022415631898000
919-Ahmad Hafeez12345003199085193000
1019-Ahmad Hafeez123450067891954000
1117-Aurangzaib Nawaz123450067326181773000
1220-weweweweee kkkiiikiikû†123400345552041000
1321-weweweweee kkkiiikiikm²123400456772124000
1421-weweweweee kkkiiikiik2 �123400678902180000
1520-edjdije ejdije12340083748922067000
1620-user 123450021474836472022000
1720-user 123450021474836472072000
"

@cobisja
Copy link
Owner

cobisja commented Dec 19, 2015

Well the response that you got from your device is obviously not well formed (according XML structure) and that's why you are getting the error:

Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xFB 0x86 0x3C 0x2F in C:\Program Files (x86)\xampp\htdocs\hrm\libraries\tad\lib\TADResponse.php on line 462

It's suppose your device should be return an XML response like the following:

<GetAllUserInfoResponse>
    <Row>
        <PIN>XXXXX</PIN>
        <Name>XXXX</Name>
        <Password>XXX</Password>
        <Group>X</Group>
        <Privilege>X</Privilege>
        <Card>XXXX</Card>
        <PIN2>XXXX</PIN2>
        <TZ1>XXX</TZ1>
        <TZ2>XXX</TZ2>
        <TZ3>XXX</TZ3>
    </Row>
    <Row>
       ...
    </Row>
</GetAllUserInfoResponse>

I have no idea why you are getting a not well-formed XML. Maybe is your device model (which I don't know what model you have, by the way). Maybe is the device's firmware version (TAD-PHP it's been tested on ZEM580, ZEM600 and few devices with ZEM800).

Sorry but at the moment I don't have any advice for you to solve this issue.

@JohanMa4
Copy link

Hi @ahmedali5530 the problem is how are you sending data, if you look at line: "1421-weweweweee kkkiiikiik2 �123400678902180000", you can see a "diamond" with a question mark inside, that is the problem on sending XML data and convert it.

I think the solution is send the data without that signs or symbols.

I hope this help you.

@cobisja
Copy link
Owner

cobisja commented Dec 23, 2015

Maybe I'm wrong my friend but I agree with @JohanMa4. I think the problem is related with your data in your device.

It would be nice if you can tell me what device's model you have (including the firmware version).

@ahmedali5530
Copy link
Author

Thanks @cobisja and @JohanMa4 for your suggestions, i deleted the users with different encoding and it worked.
By the way i m using Zkteco F18 machine.

@erlangparasu
Copy link

@cobisja @ahmedali5530 Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants