Login and post message using script
Posted: Wed Jul 21, 2004 5:25 am
I am just playing and tesign some stuff out.
I want to create a script that can login to a forum, then a post a message on my behalf. Obviously, i am needing to send all my info through POST.
I found this script, but I can't get it to work. I filled all the parameter correctly, but all it returns is the following message:
any ideas hopw i can achieve this
I want to create a script that can login to a forum, then a post a message on my behalf. Obviously, i am needing to send all my info through POST.
I found this script, but I can't get it to work. I filled all the parameter correctly, but all it returns is the following message:
HTTP/1.1 302 Moved Temporarily Connection: close Date: Wed, 21 Jul 2004 10:19:37 GMT Server: Microsoft-IIS/6.0 Set-Cookie: UID=E13696D9%2DEC59%2DA254%2D6754BFEEA629FCD6;path=/ Set-Cookie: READTOPICS=;path=/ location: /members/login.cfm Content-Type: text/html; charset=ISO-8859-1
Code: Select all
/* sendToHost
* ~~~~~~~~~~
* Params:
* $host - Just the hostname. No http:// or
/path/to/file.html portions
* $method - get or post, case-insensitive
* $path - The /path/to/file.html part
* $data - The query string, without initial question mark
* $useragent - If true, 'MSIE' will be sent as
the User-Agent (optional)
*
* Examples:
* sendToHost('www.google.com','get','/search','q=php_imlib');
* sendToHost('www.example.com','post','/some_script.cgi',
* 'param=First+Param&second=Second+param');
*/
function sendToHost($host,$method,$path,$data,$useragent=0)
{
// Supply a default method of GET if the one passed was empty
if (empty($method)) {
$method = 'GET';
}
$method = strtoupper($method);
$fp = fsockopen($host, 80);
if ($method == 'GET') {
$path .= '?' . $data;
}
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
if ($useragent) {
fputs($fp, "User-Agent: MSIE\r\n");
}
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') {
fputs($fp, $data);
}
while (!feof($fp)) {
$buf .= fgets($fp,128);
}
fclose($fp);
return $buf;
}