Chinaunix

标题: PHP curl http提交 [打印本页]

作者: Digico    时间: 2006-10-31 11:39
标题: PHP curl http提交
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://bbs.chinaunix.net/logging.php?action=login");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/99.99 (compatible; MSIE 99.99; Windows XP 99.99)");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strLoginData);
curl_setopt ($ch, CURLOPT_COOKIEFILE, 'cookie.txt');    //记录cookie.txt
curl_exec($ch);



//ini_set('display_errors', 1);
//error_reporting(E_ALL ^ E_NOTICE);
//header("Content-type:text/html;charset=utf-8");

set_time_limit(5);

$referer = 'http://www.12530.com';
$data = 'Hello PHPX!';
$host = "www.12530.com";
$path = "/happy/index.php";
$port = '80';
$user = 'rbt';
$pswd = 'rbt123';


// {{{ 方法 1 ,用 fsockopen
/*
// 处理好 formhash 的值就可以实现登录,这里还不可以,弄过discuz的可以尝试一下
$path = "/happy/logging.php?action=login";
$data = "formhash=&referer=$referer&loginmode=normal&cookietime=2592000&loginfield=username&username=$user&password=$pswd&questionid=0";

(Request-Line):GET / HTTP/1.1
Accept:*/*
Accept-Languag

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/1184/showart_192912.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2