承接 blesta/pterodactyl-sdk 相关项目开发

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

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

blesta/pterodactyl-sdk

最新稳定版本:1.3.1

Composer 安装命令:

composer require blesta/pterodactyl-sdk

包简介

Pterodactyl SDK

README 文档

README

This is an SDK that integrates with APIs from Pterodactyl Docs.

Installation

You can install the SDK via composer:

composer require blesta/pterodactyl-sdk

Usage

Initializing the API

$useSsl = true;
$api = new \Blesta\PterodactylSDK\PterodactylApi('API_KEY', 'PANEL_URL', $useSsl);

One thing to note is that the Pterodactyl Panel has two API's: The application API and the account API. The account API/key should be used to access the Client requestor, while the application API/key should be used for all other requestors.

Loading a Requestor

Requestor definition: A class that the SDK uses to access API endpoints of a particular type (e.g. Servers, Nests, or Locations).

The SDK utilizes PHP's __get() magic method so requestors can just be accessed as a property of the loaded api. For example:

$clientRequestor = $api->Client;

Calling an Endpoint

All endpoints exist as a method on a requestor. For example, the application/locations/ endpoint would be called as follows:

$locationResponse = $api->Locations->getAll();

Or to call the same endpoint but with post parameters to add a new location, it would look like this:

$locationResponse = $api->Locations->add($parameters);

Using a response object

The response object is meant to make it easier to Access the returned data and recognize when you have encountered errors. It has the following methods:

$locationResponse->raw(); // Useful for logging the full response from Pterodactyl
$locationResponse->response(); // The json decoded data returned
$locationResponse->headers(); // An array of http headers returned
$locationResponse->status(); // The status code returned
$locationResponse->errors(); // An array of the errors returned

The most used methods are typically response() and errors()

$errors = $locationResponse->errors();
if (empty($errors)) {
    $locations = $locationResponse->response();
    ...
    ...
    ...
}

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2019-10-24