ホームページ >バックエンド開発 >PHPチュートリアル >request_by_socket 配信データ部門についてはどうですか?
request_by_socket提交数据部行的呢?
$post_string = "app=socket&version=beta&username=".$userid."&pwd=".$userpwd."";
$re = request_by_socket('xinqq163.com','/api/xinqq_login.php',$post_string);
echo $re;
function request_by_socket($remote_server, $remote_path, $post_string, $port = 80, $timeout = 30)
{
$socket = fsockopen($remote_server, $port, $errno, $errstr, $timeout);
if (!$socket) die("$errstr($errno)");
fwrite($socket, "POST $remote_path HTTP/1.0rn");
fwrite($socket,"ユーザー エージェント: ソケットの例rn");
fwrite($socket, "HOST: $remote_serverrn");
fwrite($socket,"Content-type: application/x-www-form-urlencodedrn");
fwrite($socket, "Content-length: " . (strlen($post_string) 8) . 'rn');
fwrite($socket,"Accept:*/*rn");
fwrite($socket, "rn");
fwrite($socket, "mypost=$post_stringrn");
fwrite($socket, "rn");
$header = "";
while ($str = trim(fgets($socket, 4096))) {
$header .= $str;
}
$data = "";
while (!feof($socket)) {
$data .= fgets($socket, 4096);
}
$data を返す;
}
错误ヒント:
411 長さ 必須