PHP analog post submission data, useful, can be used for site collection, landing and so on
Take the forum login in my project for example
function A_bbslogin ($user _login, $password, $host, $port = "80") {
Post data that needs to be submitted
$ARGV = Array (
' Cookie ' => array (' User_login ' => $user _login, ' password ' => $password, ' _wp_http_referer ' => '/bbpress/', ' Re ' => ', ' Remember ' =>true)
);
foreach ($argv [' Cookie '] as $key => $value) {
$params [] = $key. '=' . $value;
}
$params = Implode (' & ', $params);
$header = "post/bbpress/bb-login.php http/1.1rn";
$header. = "Host: $host: $portrn";
$header. = "CONTENT-TYPE:APPLICATION/X-WWW-FORM-URLENCODEDRN";
$header. = "Content-length:". Strlen ($params). "RN";
$header. = "Connection:closernrn";
$header. = $params;
$fp = Fsockopen ($host, $port);
Fputs ($fp, $header);
while (!feof ($fp)) {//
$str = fgets ($FP); Here is your own logical code, which is primarily an analog cookie that can be used to log in synchronously
if (!) ( Strpos ($str, "Set-cookie:") = = False)) {
$tmparray = Explode ("", $str);
$cookiearray = explode ("=", $tmparray [1]);
$cookiepaths = explode ("=", $tmparray [6]);
$cookiename = UrlDecode ($cookiearray [0]);
$cookievalue = UrlDecode (substr ($cookiearray [1],0,strlen ($cookiearray [1])-1);
$cookietime = time () +3600*24*7;
$cookiepath = UrlDecode (substr ($cookiepaths [1],0,strlen ($cookiepaths [1])-1);
Setcookie ($cookiename, $cookievalue, $cookietime, $cookiepath);
}
}
Fclose ($FP);
}