01.
$fp
=
fsockopen
(
"xxx.xx.xx.xxx"
, 80,
$errno
,
$errstr
, 30);
02.
if
(!
$fp
) {
03.
echo
"$errstr ($errno)<br />\n"
;
04.
}
else
{
05.
$reqPkg
=
"POST /tunnel/servlet/sendSMS.do HTTP/1.1\r\n"
;
06.
$reqPkg
.=
"Host: xxx.xx.xx.xxx\r\n"
;
07.
$reqPkg
.=
"Content-type: text/xml; charset=UTF-8\r\n"
;
08.
$reqPkg
.=
"Authorization: $authenHeader\r\n"
;
09.
$reqPkg
.=
"Connection: close\r\n"
;
10.
$reqPkg
.=
"Content-Length: "
.
strlen
(
$postData
) .
"\r\n\r\n"
;
11.
$reqPkg
.=
"$postData"
;
12.
13.
14.
15.
fwrite(
$fp
,
$reqPkg
);
16.
while
(!
feof
(
$fp
)) {
17.
$respData
.=
fgets
(
$fp
, 128);
18.
19.
}
20.
fclose(
$fp
);
21.
}
22.
23.
$s1
=
strpos
(
$respData
,
"<status>"
)+8;
24.
$s2
=
strpos
(
$respData
,
"</status>"
);
25.
$code
=
substr
(
$respData
,
$s1
,
$s2
-
$s1
);