lghost/api

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP REST SDK for LGHOST API(s)

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

This package is auto-updated.

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


README

PHP SDK for LGHOST RESTful APIs

Allows communication with https://api.lghost.co.uk/

Quickstart

To download this library and integrate it inside your PHP application, you can use Composer.

Quick integration with the following command:

composer require lghost/api

Then, you can install LGHOST APIs library and dependencies with:

php composer.phar install

This will install lghost/api to ./vendor, along with other dependencies including autoload.php.

How to use LGHOST API to check OS Availabilities for servers?

<?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 />"));
}

This will output you the following:

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
)