这个地方是发送
   public function submit_url($submit_url,$,$str_message)
   {
        //生成提交串
        $str_post_data = array ($ =>$str_message);        //提交强求
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $submit_url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        // 我们在POST数据哦!
        curl_setopt($ch, CURLOPT_POST, 1);
        // 把post的变量加上
        curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post_data);
        $str_content = curl_exec($ch);
        curl_close($ch);        echo $str_content;
        return $str_content;
   }然后post 到一个adduser.php 这时候我需要初始化我的logger
$logger = new logger(__DIR__.'/logs');    public function __construct($log_directory, $log_level_threshold = LogLevel::DEBUG)
    {
        $this->log_level_threshold = $log_level_threshold;        $log_directory = rtrim($log_directory, '\\/');
        if (! file_exists($log_directory)) {
            mkdir($log_directory, $this->default_permissions, true);
        }        $this->log_file_path = $log_directory.DIRECTORY_SEPARATOR.'log_'.date('Y-m-d').'.txt';
        if (file_exists($this->log_file_path) && !is_writable($this->log_file_path)) {
            throw new RuntimeException('无法写入指定文件请检查文件权限设置');
        }        $this->file_handle = fopen($this->log_file_path, 'a');
        if ( ! $this->file_handle) {
            throw new RuntimeException('无法打开指定文件请检查文件权限设置');
        }
    }这是logger的construct,我是初学php,不知道怎么拿到post过去以后那边页面报的错
如果我用浏览器直接打开adduser.php或者 直接执行php adduser.php 都没有问题

解决方案 »

  1.   

    没有权限判断,就是接收一个$_POST[]数据的很简单php文件,我现在需要在那个文件记录日志
    我现在发现的问题就是curl  redirect 到一个php页面,那个php页面没有 文件写出权限 
      

  2.   

    贴出 $submit_url 的值
    和 echo $str_content; 的结果
      

  3.   

    http://127.0.0.1/eventbus/source/adduser.php结果就是 在 $logger = new logger(__DIR__.'/logs');之前的echo都有
    执行到$logger = new logger(__DIR__.'/logs');就停了,也没显示什么错误
      

  4.   

    curl_setopt($ch, CURLOPT_URL, $submit_url);
    curl_setopt($ch, CURLOPT_HEADER, true); //加上这句,再看结果
      

  5.   

    HTTP/1.0 500 Internal Server Error
    Date: Wed, 23 Apr 2014 06:52:32 GMT
    Server: Apache/2.4.6 (Ubuntu)
    X-Powered-By: PHP/5.5.3-1ubuntu2.3
    Content-Length: 3
    Connection: close
    Content-Type: text/htmlHTTP/1.1 100 Continue加上以后返回了这个
      

  6.   

    500 错!拒绝访问
    显然你的程序 adduser.php 有严重的问题直接浏览器访问 http://127.0.0.1/eventbus/source/adduser.php
    好像你说可以
    写个表单提交到 http://127.0.0.1/eventbus/source/adduser.php
      

  7.   

    最大的可能是类 logger 定义文件没加载
      

  8.   

    那个文件肯定加载了的,我特别试过,注释掉constructor里面打开文件的操作
    初始化就没问题了,说明就是文件操作导致的问题
      

  9.   

    这么复杂的想法,curl 不就是抓取吗?