我试图将指纹机连接到php,然后我尝试在htdocs / machine / get-data.php中执行代码并在浏览器中输入localhost / machine / get-data.php,
但会显示错误消息:
警告:fsockopen():无法连接到192.168.1.35:80(连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接主机无法响应而建立连接失败。)
以下是我尝试连接指纹X100-C机器的代码:
get-data.php
<?
$IP=$_GET["ip"];
$Key=$_GET["key"];
if($IP=="") $IP="192.168.1.201";
if($Key=="") $Key="0";
?>
<form action="tarik-data.php">
IP Address: <input type="Text" name="ip" value="<?=$IP?>" size=15><BR>
Comm Key: <input type="Text" name="key" size="5" value="<?=$Key?>"><BR><BR>
<input type="Submit" value="Download">
</form>
<BR>
<?
if($_GET["ip"]!=""){?>
<table cellspacing="2" cellpadding="2" border="1">
<tr align="center">
<td><B>UserID</B></td>
<td width="200"><B>Tanggal & Jam</B></td>
<td><B>Verifikasi</B></td>
<td><B>Status</B></td>
</tr>
<?
$Connect = fsockopen($IP, "80", $errno, $errstr, 1);
if($Connect){
$soap_request="<GetAttLog><ArgComKey xsi:type=\"xsd:integer\">".$Key."</ArgComKey><Arg><PIN xsi:type=\"xsd:integer\">All</PIN></Arg></GetAttLog>";
$newLine="\r\n";
fputs($Connect, "POST /iWsService HTTP/1.0".$newLine);
fputs($Connect, "Content-Type: text/xml".$newLine);
fputs($Connect, "Content-Length: ".strlen($soap_request).$newLine.$newLine);
fputs($Connect, $soap_request.$newLine);
$buffer="";
while($Response=fgets($Connect, 1024)){
$buffer=$buffer.$Response;
}
}else echo "Koneksi Gagal";
include("parse.php");
$buffer=Parse_Data($buffer,"<GetAttLogResponse>","</GetAttLogResponse>");
$buffer=explode("\r\n",$buffer);
for($a=0;$a<count($buffer);$a++){
$data=Parse_Data($buffer[$a],"<Row>","</Row>");
$PIN=Parse_Data($data,"<PIN>","</PIN>");
$DateTime=Parse_Data($data,"<DateTime>","</DateTime>");
$Verified=Parse_Data($data,"<Verified>","</Verified>");
$Status=Parse_Data($data,"<Status>","</Status>");
?>
<tr align="center">
<td><?echo $PIN?></td>
<td><?=$DateTime?></td>
<td><?=$Verified?></td>
<td><?=$Status?></td>
</tr>
<?}?>
</table>
<?}?>
请帮我如何将指纹连接到php脚本,以及为什么我无法连接到指纹。
*我试过:*