request_by_socket交付数据部行的呢
程序员文章站
2024-02-07 21:30:46
...
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.0\r\n");
fwrite($socket, "User-Agent: Socket Example\r\n");
fwrite($socket, "HOST: $remote_server\r\n");
fwrite($socket, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($socket, "Content-length: " . (strlen($post_string) + 8) . '\r\n');
fwrite($socket, "Accept:*/*\r\n");
fwrite($socket, "\r\n");
fwrite($socket, "mypost=$post_string\r\n");
fwrite($socket, "\r\n");
$header = "";
while ($str = trim(fgets($socket, 4096))) {
$header .= $str;
}
$data = "";
while (!feof($socket)) {
$data .= fgets($socket, 4096);
}
return $data;
}
错误提示:
411 Length Required
------解决方案--------------------
Content-Length
------解决方案--------------------
411 Length Required:服务器拒绝在没有定义Content-Length头的情况下接受请求. 在添加了表明请求消息体长度的有效Content-Length头之后,客户端可以再次提交该请求。
------解决方案--------------------
1.别把用户名和密码都贴上来,用相同数量*号就看明白了……快去改密码吧
2.HTTP/1.1 200 OK不就是返回正确了么?
$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.0\r\n");
fwrite($socket, "User-Agent: Socket Example\r\n");
fwrite($socket, "HOST: $remote_server\r\n");
fwrite($socket, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($socket, "Content-length: " . (strlen($post_string) + 8) . '\r\n');
fwrite($socket, "Accept:*/*\r\n");
fwrite($socket, "\r\n");
fwrite($socket, "mypost=$post_string\r\n");
fwrite($socket, "\r\n");
$header = "";
while ($str = trim(fgets($socket, 4096))) {
$header .= $str;
}
$data = "";
while (!feof($socket)) {
$data .= fgets($socket, 4096);
}
return $data;
}
错误提示:
411 Length Required
------解决方案--------------------
Content-Length
------解决方案--------------------
411 Length Required:服务器拒绝在没有定义Content-Length头的情况下接受请求. 在添加了表明请求消息体长度的有效Content-Length头之后,客户端可以再次提交该请求。
------解决方案--------------------
1.别把用户名和密码都贴上来,用相同数量*号就看明白了……快去改密码吧
2.HTTP/1.1 200 OK不就是返回正确了么?
相关文章
相关视频
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论