coulterpeterson/cloudways-api

一个包含一系列Cloudways API的类,便于使用。所有Cloudways文档中可用的API都包含在内。祝您编码愉快。

v1.0.2 2023-10-30 02:33 UTC

This package is auto-updated.

Last update: 2024-09-30 01:47:23 UTC


README

mohamedshuaau/cloudways-api 分支。

此API是为了使您的编码体验更加轻松,并帮助您在不添加额外代码的麻烦中快速开始。此包包含一个类,其中包含官方API文档中所有可用的函数。

请注意,这些函数中的一些可能不会按预期工作,因为Cloudways API仍处于测试版本。一些URL的输出不是预期的结果。

安装

composer require coulterpeterson/cloudways-api

此包需要guzzlehttp才能工作,但它将自动与该包一起安装。如果您仍在guzzle方面遇到问题,请手动安装:

composer require guzzlehttp/guzzle

对于正常使用案例,或者如果您只想单独包含类文件,请随时下载文件并方便使用。

用法

如前所述,该类包含Cloudways中所有可用的RESTAPI调用。要查看可用的函数,请访问Cloudways官方文档: https://developers.cloudways.com/docs/ 在这里您可以找到所有信息、所需参数和值的类型。

基本用法

// Use Composer's autoload (if using Laravel, the package will be loaded as a service automatically)
require_once 'vendor/autoload.php';

//Here is where you define the email address and your API key from Cloudways  
$CW_API = new \CoulterPeterson\CloudwaysApi\CloudwaysAPIClient('example@gmail.com', 'API_KEY');  

//Magic
$server_settings = $CW_API->get_server_settings('12345');   // (Server ID)

//object to json
$json = json_encode($server_settings);  

//json to json array
$decode = json_decode($json, true);  

return $decode;

预期结果

{"settings":{"apc.shm_size":"32","character_set_server":"ascii","date.timezone":"","display_errors":"Off","error_reporting":"E_ALL & ~E_DEPRECATED & ~E_STRICT","execution_limit":"60","innodb_buffer_pool_size":"","innodb_lock_wait_timeout":"","key_buffer_size":"","max_connections":"150","max_input_time":"60","max_input_vars":"2500","memory_limit":"128","mod_xdebug":"disable","nginx_http2":"enable","package_versions":{"fpm":"enable","mariadb":"","mysql":"5.7","php":"7.3","redis":""},"short_open_tag":"off","static_cache_expiry":"43200","upload_size":"10","wait_timeout":""}}

原始结果以对象形式出现,我们使用json_encode将其转换为JSON。然后,我们使用带有第二个参数truejson_decode将其转换为JSON数组。输出如上述示例所示。

大约有140个函数可用,这些函数的名称与Cloudways文档中给出的名称相对应。

请参阅函数列表,以获取所有可用函数和所需参数。

请随时提出建议或问题。您的建议和帮助始终欢迎。祝您编码愉快! :)