本帖最后由 life169 于 2010-12-06 14:29:33 编辑

解决方案 »

  1.   

    cookie得获取(http 返回头中的set-Cookie项)并反馈过去(http请求头中的cookie项)。$login_url = "http://www.czhi-fi.com/bbsxp/login.asp";//登录页地址
    $source_url = "http://www.czhi-fi.com/bbsxp/default.asp";//源页地址
    $post_fields = array();
    //以下两项固定值
    /*$post_fields['menu'] = 'add';
    $post_fields['url'] = 'http://www.czhi-fi.com/bbsxp/Default.asp';//用户名和密码,必须填写
    $post_fields['username'] = "mytest";
    $post_fields['userpass'] = "111111";*/
    $cookie="cookie.txt";
    $ch = curl_init($login_url);
    curl_setopt($ch, CURLOPT_REFERER, $source_url);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=mytest&userpass=111111&menu=add&url=http://www.czhi-fi.com/bbsxp/Default.asp');
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 允许自动跳转
    $contents = curl_exec($ch);
    curl_close($ch);
    echo $contents;
      

  2.   

    高手就是高手感谢 “foolbirdflyfirst”作答。Thank you!