lghost/api

此软件包已被废弃且不再维护。没有建议替代包。

LGHOST API 的 PHP REST SDK

v1.0 2019-07-07 03:15 UTC

This package is auto-updated.

Last update: 2021-08-07 07:49:56 UTC


README

LGHOST RESTful API 的 PHP SDK

允许与 https://api.lghost.co.uk/ 进行通信

快速入门

要下载此库并将其集成到您的 PHP 应用程序中,您可以使用 Composer

使用以下命令进行快速集成

composer require lghost/api

然后,您可以使用以下命令安装 LGHOST API 库及其依赖项

php composer.phar install

这将安装 lghost/api./vendor,包括其他依赖项,如 autoload.php

如何使用 LGHOST API 检查服务器的操作系统可用性?

<?php
/** 
 * ----------------------------------------------------
 * Library: 		LHOST API REST SDK
 * File: 			Index.php
 * Description:		Test example
 * API URL: 		https://api.lghost.co.uk/
 * ----------------------------------------------------
 * Copyright 2015-2019 LiveGuard Software Ltd. All rights reserved.
**/

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

use \LGHOST\Api\ApiClient;

try {
	
	$lghost = new ApiClient(
			[ 'key' => '', 'secret' => '' ], // Optional - For calls that need authentication
			'lghost-eu-v1', 				 // Requires - Valid region
			['debug' => false]);			 // Optional - Show debug messages
				
	$result = $lghost->GET('/dedicated/server/osAvailabilities', [ 
			'hardwareModel' => '19adv01.ram-32g-ecc-2400.softraid-2x500nvme' /** Hardware model/reference */
			]);
			
	// Optional - Here we can check return as array, just specify true		
	$object = $result->json(false);
	
	// Optional - Here we can check for Code returned
	if($object->Code === 200)
	{
		print_r($object->osAvailabilities);
	}
		
} catch (\LGHOST\Exceptions\InvalidParameterException $e) {
	((PHP_SAPI == 'cli') ? print("Caught " . $e->getMessage() . "\r\n") : print("Caught <strong>" . $e->getMessage() . "</strong> <br /><br />"));
} catch (\LGHOST\Exceptions\HttpException $e) {
	((PHP_SAPI == 'cli') ? print("Caught " . $e->getMessage() . "\r\n") : print("Caught <strong>" . $e->getMessage() . "</strong> <br /><br />"));
}

这将输出以下内容

Array
(
    [0] => ubuntu1904-server_64
    [1] => debian9-ispconfig3_64
    [2] => cloudlinux7_64
    [3] => coreos-alpha_64
    [4] => solusvm-slave-vz_64
    [5] => fedora28_64
    [6] => proxmox5_64
    [7] => debian9-plesk17_64
    [8] => win2019-std_64
    [9] => proxmox5-zfs_64
    [10] => centos7-cpanel-latest_64
    [11] => win2019core-dc_64
    [12] => ubuntu1810-server_64
    [13] => xenserver74_64
    [14] => ubuntu1804-server_64
    [15] => ubuntu1604-server_64
    [16] => win2019-dc_64
    [17] => debian8_64
    [18] => debian8-ispconfig3_64
    [19] => coreos_64
    [20] => esxi67_64
    [21] => ubuntu1604-desktop_64
    [22] => centos6_64
    [23] => gentoo11_64
    [24] => freebsd11-zfs_64
    [25] => archlinux-installer_64
    [26] => win2019-hyperv_64
    [27] => fedora29_64
    [28] => centos6-cpanel-latest_64
    [29] => esxi60_64
    [30] => win2019core-std_64
    [31] => esxi65_64
    [32] => debian9_64
    [33] => centos7-plesk17_64
    [34] => win2016-std_64
    [35] => opensuse42_64
    [36] => centos7-directadmin_64
    [37] => win2016-dc_64
    [38] => centos7_64
    [39] => solusvm-master-vz_64
)