承接 eugenevdm/whm-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eugenevdm/whm-api

最新稳定版本:v0.0.1

Composer 安装命令:

composer require eugenevdm/whm-api

包简介

WHM/cPanel API for PHP

README 文档

README

Contents

Installation Guide

To install this package, you can run this code via your terminal:

	composer require eugenevdm/whm-api

Usage

If you would like to get list accounts of your WHM server you can do this:

<?php

    require_once __DIR__ . '/vendor/autoload.php';

    use Eugenevdm\WhmApi\Cpanel;  
  
    $cpanel = new src\Cpanel([
        'host'        =>  'https://1.2.3.4:2087', // ip or domain complete with its protocol and port
        'username'    =>  'root', // username of your server, it is usually root
        'auth_type'   =>  'hash', // set 'hash' or 'password'
        'password'    =>  'password', // long hash or your user's password
    ]);

    $accounts = $cpanel->listaccts(); // results returned as an array
  
    echo print_r($accounts, true);

Functions

Defining Configuration on constructor

This is the example when you want to define your configuration while creating new object

  <?php
  
  $cpanel = new src\Cpanel([
      'host'        =>  'https://1.2.3.4:2087', // required
      'username'    =>  'root', // required
      'auth_type'   =>  'hash', // optional, default 'hash'
      'password'    =>  'password', // required
  ]);

Usage

For example, you would like to get some list accounts from WHM/cPanel

	<?php

	$accounts = $cpanel->listaccts();

	// passing parameters
	$accounts = $cpanel->listaccts(['searchtype'=>'domain', 'search'=>'', 'exact', 'search'=>'helloworld.com']);
	
	// create account (Domain Name, Username, Password, Plan Slug)
	createAccount(www.domain_name.com.br, 'user', 'pass', 'plan_basic');

For accessing cPanel API 2, you can use this.

	<?php
	// get bandwidth data of specific cPanel's user
	$data = $cpanel->cpanel('Bandwidth', 'getbwdata', 'username');

	// removing cron line
	$data = $cpanel->cpanel('Cron', 'remove_line', 'username', ['line'=>1]);

The first parameter must be Module you would like to get, second is function name, and the third is username of cPanel's user. There is fourth arguments, when function has some additional arguments, you can pass it there.

For accessing to cPanel API 1 or cPanel API 2 or UAPI, you can use this.

	<?php
	// get bandwidth data of specific cPanel's user (using cPanel API 2)
	$data = $cpanel->execute_action('2', 'Bandwidth', 'getbwdata', 'username');

	// removing email address (using UAPI)
	$data = $cpanel->execute_action('3', 'Email', 'delete_pop', 'username', ['email'=>'peter@griffin.com']);

This function is similar to the above, the only difference is that it has added a parameter which indicates the API you want to use (1 = cPanel API 1, 2 = cPanel API 2, 3 = UAPI), the other arguments are the same.

Overriding current configuration

Somehow, you want to override your current configuration. To do this, here is the code

  <?php
  // change username and (password or hash)
  $cpanel->setAuthorization($username, $password);

  // change host
  $cpanel->setHost($host);

  // change authentication type
  $cpanel->setAuthType($auth_type);

Get defined configuration

After you define some of your configuration, you can get it again by calling this functions

  <?php
  // get username
  $cpanel->getUsername();

  // get password
  $cpanel->getPassword();

  // get authentication type
  $cpanel->getAuthType();

  // get host
  $cpanel->getHost();

Feedback and contribution

Pull requests are super welcome :-)

统计信息

  • 总下载量: 320
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 89
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固