这个地方是发送
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 都没有问题
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 都没有问题
我现在发现的问题就是curl redirect 到一个php页面,那个php页面没有 文件写出权限
和 echo $str_content; 的结果
执行到$logger = new logger(__DIR__.'/logs');就停了,也没显示什么错误
curl_setopt($ch, CURLOPT_HEADER, true); //加上这句,再看结果
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加上以后返回了这个
显然你的程序 adduser.php 有严重的问题直接浏览器访问 http://127.0.0.1/eventbus/source/adduser.php
好像你说可以
写个表单提交到 http://127.0.0.1/eventbus/source/adduser.php
初始化就没问题了,说明就是文件操作导致的问题