当前位置:论坛首页 > Linux面板 > 求助

邮局管理器4.2api添加用户 出错

发表在 Linux面板2021-4-9 11:45 [复制链接] 0 1729

提示消息

{"status":false,"msg":"\u62b1\u6b49\uff0c\u51fa\u9519\u4e86\uff1a
Traceback (most recent call last):
  File \"class\/flask_sockets.py\", line 30, in __call__
    handler, values = adapter.match()
  File \"\/www\/server\/panel\/pyenv\/lib\/python3.7\/site-packages\/werkzeug\/routing.py\", line 1945, in match
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"class\/panelPlugin.py\", line 1948, in a
    return eval(execStr)
  File \"\", line 1, in
  File \"plugin\/mail_sys\/mail_sys_main.py\", line 1063, in add_mailbox
    num, unit = args.quota.split()
ValueError: not enough values to unpack (expected 2, got 1)
"}

php请求源码
<?php
class bt_api {
    private $BT_KEY = "thVLXFtUCCNzBShBweKTPBmw8296q8R8";  //接口密钥
      private $BT_PANEL = "http://127.0.0.1:8888";       //面板地址
   
      //如果希望多台面板,可以在实例化对象时,将面板地址与密钥传入
    public function __construct($bt_panel = null,$bt_key = null){
        if($bt_panel) $this->BT_PANEL = $bt_panel;
        if($bt_key) $this->BT_KEY = $bt_key;
    }
   
      //示例取面板日志   
    public function GetLogs(){
        //拼接URL地址
        $url = $this->BT_PANEL.'/plugin?action=a&name=mail_sys&s=add_mailbox';
        
        //准备POST数据
        $p_data = $this->GetKeyData();        //取签名
        $p_data['quota'] = 1+MB;
        $p_data['username'] = 111@mail.com';
        $p_data['password'] = '111@MAIL.com';
        $p_data['full_name'] = '111';
        $p_data['is_admin'] = '0';
        
        //请求面板接口
        $result = $this->HttpPostCookie($url,$p_data);
        
        //解析JSON数据
        $data = json_decode($result,true);
          return $data;
    }
   
   
      /**
     * 构造带有签名的关联数组
     */
      private function GetKeyData(){
          $now_time = time();
        $p_data = array(
            'request_token'    =>    md5($now_time.''.md5($this->BT_KEY)),
            'request_time'    =>    $now_time
        );
        return $p_data;   
    }
      
  
      /**
     * 发起POST请求
     * @param String $url 目标网填,带http://
     * @param Array|String $data 欲提交的数据
     * @return string
     */
    private function HttpPostCookie($url, $data,$timeout = 60)
    {
        //定义cookie保存位置
        $cookie_file='./'.md5($this->BT_PANEL).'.cookie';
        if(!file_exists($cookie_file)){
            $fp = fopen($cookie_file,'w+');
            fclose($fp);
        }
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }
}



//实例化对象
$api = new bt_api();
//获取面板日志
$r_data = $api->GetLogs();
//输出JSON数据到浏览器
echo json_encode($r_data);
?>


使用道具 举报 只看该作者 回复
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表