Git Product home page Git Product logo

pterodactyl-sdk's People

Contributors

belzaaron avatar jewome62 avatar joshtrebilco avatar jwaldecker avatar sergejkembel avatar the-mg avatar tlingc avatar tyson239 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pterodactyl-sdk's Issues

403 Error

Hello, when I try to connect to my server with this library it throws a 403 error:

Fatal error: Uncaught Exception: { "errors": [ { "code": "AccessDeniedHttpException", "status": "403", "detail": "An error was encountered while processing this request." } ] } in /home/absolutg/public_html/query/pterodactyl/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php:121 Stack trace: #0 /home/absolutg/public_html/query/pterodactyl/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(95): HCGCloud\Pterodactyl\Pterodactyl->handleRequestError(Object(GuzzleHttp\Psr7\Response)) #1 /home/absolutg/public_html/query/pterodactyl/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(21): HCGCloud\Pterodactyl\Pterodactyl->request('GET', 'api/application...') #2 /home/absolutg/public_html/query/pterodactyl/vendor/hcgcloud/pterodactyl-sdk/src/Actions/ManagesServers.php(32): HCGCloud\Pterodactyl\Pterodactyl->get('api/application...') #3 /home/absolutg/public_html/query/pterodactyl/index.php(6): HCGCloud\Pterodactyl\Pterodactyl->server('ddca964e') #4 {ma in /home/absolutg/public_html/query/pterodactyl/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php on line 121

My Code:

<?php 
require_once("vendor/autoload.php"); 

$pterodactyl = new \HCGCloud\Pterodactyl\Pterodactyl('API_KEY_HIDDEN', 'URL_HIDDEN');

$server = $pterodactyl->server('SERVER_ID_HIDDEN');

$egg = $pterodactyl->egg($nest_id, $egg_id);
$server = $pterodactyl->createServer([
    "external_id" => $external_id,
    "name" => $name,
    "user" => $user_id,
    "egg" => $egg_id,
    "pack" => 0,
    "docker_image" => $egg->dockerImage,
    "skip_scripts" => false,
    "environment" => [],
    "limits" => [
        "memory" => $memory,
        "swap" => $swap,
        "disk" => $disk,
        "io" => $io,
        "cpu" => $cpu
    ],
    "feature_limits" => [
        "databases" => $databases,
        "allocations" => $allocations
    ],
    "startup" => $egg->startup,
    "description" => "",
    "deploy" => [
        "locations" => [$location_id],
        "dedicated_ip" => false,
        "port_range" => []
    ],
    "start_on_completion" => true
]);

echo $server;
?>

I have been unable to find out how to resolve it, please help me.

Thanks,
Tommy Vange

NoViableNodeException

When I try to create a server I get this error:

Fatal error: Uncaught HCGCloud\Pterodactyl\Exceptions\FailedActionException: {"errors":[{"code":"NoViableNodeException","status":"400","detail":"No nodes satisfying the requirements specified for automatic deployment could be found."}]} in /Applications/XAMPP/xamppfiles/htdocs/projects/pterdoctaly/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php:125 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/projects/pterdoctaly/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(101): HCGCloud\Pterodactyl\Pterodactyl->handleRequestError(Object(GuzzleHttp\Psr7\Response)) #1 /Applications/XAMPP/xamppfiles/htdocs/projects/pterdoctaly/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(35): HCGCloud\Pterodactyl\Pterodactyl->request('POST', 'api/application...', Array) #2 /Applications/XAMPP/xamppfiles/htdocs/projects/pterdoctaly/vendor/hcgcloud/pterodactyl-sdk/src/Actions/ManagesServers.php(57): HCGCloud\Pterodactyl\Pterodactyl->post('api/application...', Array) #3 /Applications/XAMPP/xamppfiles/htdocs/project in /Applications/XAMPP/xamppfiles/htdocs/projects/pterdoctaly/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php on line 125

This is my code:

$name = "testapi1";
    $nest_id = 1;
    $egg_id = 5;
    $location_id = 1;
    $egg = $pterodactyl->egg($nest_id, $egg_id); //get docker_image and startup directly from egg
    $server = $pterodactyl->createServer([
        // "external_id" => '110',
        "name" => $name,
        "user" => 1,
        "egg" => $egg_id,
        "docker_image" => $egg->dockerImage,
        "skip_scripts" => false,
        "environment" => [
            "SERVER_AUTOUPDATE" => '1'
        ],
        "limits" => [
            "memory" => 2564,
            "swap" => 0,
            "disk" => 1024,
            "io" => 500,
            "cpu" => 100
        ],
        "feature_limits" => [
            "databases" => 1,
            "allocations" => 2,
            "backups" => 0
        ],
        "startup" => $egg->startup,
        "description" => "",
        "deploy" => [
            "locations" => [$location_id],
            "dedicated_ip" => false,
            "port_range" => []
        ],
        "start_on_completion" => true
    ]);
    print_r($server);

What am I doing wrong?

Pterodactyl API - The given data failed to pass validation.

Hello. I tried to implement automatic creation of server by using your API, but always, after I try to run $pterodactyl->createServer(...
I get an error message that The given data did not pass the validation.

Here is the full response:
object(GuzzleHttp\Psr7\Response)#31 (6) { ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=> string(20) "Unprocessable Entity" ["statusCode":"GuzzleHttp\Psr7\Response":private]=> int(422) ["headers":"GuzzleHttp\Psr7\Response":private]=> array(8) { ["Server"]=> array(1) { [0]=> string(12) "nginx/1.18.0" } ["Content-Type"]=> array(1) { [0]=> string(16) "application/json" } ["Transfer-Encoding"]=> array(1) { [0]=> string(7) "chunked" } ["Connection"]=> array(1) { [0]=> string(10) "keep-alive" } ["Cache-Control"]=> array(1) { [0]=> string(17) "no-cache, private" } ["Date"]=> array(1) { [0]=> string(29) "Sun, 26 Sep 2021 13:11:38 GMT" } ["X-RateLimit-Limit"]=> array(1) { [0]=> string(3) "240" } ["X-RateLimit-Remaining"]=> array(1) { [0]=> string(3) "236" } } ["headerNames":"GuzzleHttp\Psr7\Response":private]=> array(8) { ["server"]=> string(6) "Server" ["content-type"]=> string(12) "Content-Type" ["transfer-encoding"]=> string(17) "Transfer-Encoding" ["connection"]=> string(10) "Connection" ["cache-control"]=> string(13) "Cache-Control" ["date"]=> string(4) "Date" ["x-ratelimit-limit"]=> string(17) "X-RateLimit-Limit" ["x-ratelimit-remaining"]=> string(21) "X-RateLimit-Remaining" } ["protocol":"GuzzleHttp\Psr7\Response":private]=> string(3) "1.1" ["stream":"GuzzleHttp\Psr7\Response":private]=> object(GuzzleHttp\Psr7\Stream)#36 (7) { ["stream":"GuzzleHttp\Psr7\Stream":private]=> resource(21) of type (stream) ["size":"GuzzleHttp\Psr7\Stream":private]=> NULL ["seekable":"GuzzleHttp\Psr7\Stream":private]=> bool(true) ["readable":"GuzzleHttp\Psr7\Stream":private]=> bool(true) ["writable":"GuzzleHttp\Psr7\Stream":private]=> bool(true) ["uri":"GuzzleHttp\Psr7\Stream":private]=> string(10) "php://temp" ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=> array(0) { } } }

Here is the error message:

Fatal error: Uncaught HCGCloud\Pterodactyl\Exceptions\ValidationException: The given data failed to pass validation. in /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php:122 Stack trace: #0 /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(101): HCGCloud\Pterodactyl\Pterodactyl->handleRequestError() #1 /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(35): HCGCloud\Pterodactyl\Pterodactyl->request() #2 /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/Actions/ManagesServers.php(57): HCGCloud\Pterodactyl\Pterodactyl->post() #3 /var/www/html/engine/createserver.php(138): HCGCloud\Pterodactyl\Pterodactyl->createServer() #4 {main} thrown in /var/www/html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php on line 122

Here is my code. I checked everything and it should work.
$server = $pterodactyl->createServer([ "external_id" => '11', "name" => "test", "user" => 1, "egg" => $egg_id, "docker_image" => $egg->dockerImage, "skip_scripts" => false, "environment" => [ "SERVER_JARFILE" => "server.jar", "VANILLA_VERSION" => "latest" ], "limits" => [ "memory" => 256, "swap" => 0, "disk" => 1024, "io" => 500, "cpu" => 100 ], "feature_limits" => [ "databases" => 1, "allocations" => 2 ], "startup" => $egg->startup, "description" => "", "deploy" => [ "locations" => [$location_id], "dedicated_ip" => false, "port_range" => [] ], "start_on_completion" => true ]); print_r($server);

Thanks in advance!

Error Creating User

Fatal error: Uncaught HCGCloud\Pterodactyl\Exceptions\ValidationException: The given data failed to pass validation. in D:\**\php\database\vendor\hcgcloud\pterodactyl-sdk\src\MakesHttpRequests.php:117 Stack trace: #0 D:\**\php\database\vendor\hcgcloud\pterodactyl-sdk\src\MakesHttpRequests.php(101): HCGCloud\Pterodactyl\Pterodactyl->handleRequestError(Object(GuzzleHttp\Psr7\Response)) #1 D:\**\php\database\vendor\hcgcloud\pterodactyl-sdk\src\MakesHttpRequests.php(35): HCGCloud\Pterodactyl\Pterodactyl->request('POST', 'api/application...', Array) #2 D:\**\php\database\vendor\hcgcloud\pterodactyl-sdk\src\Actions\ManagesUsers.php(56): HCGCloud\Pterodactyl\Pterodactyl->post('api/application...', Array) #3 D:\**\php\database\register-handler.php(61): HCGCloud\Pterodactyl\Pterodactyl->createUser(Array) #4 {main} thrown in D:\**\php\database\vendor\hcgcloud\pterodactyl-sdk\src\MakesHttpRequests.php on line 117

Can some one help me?

I can't create a user.

So this is my code
$user = $pterodactyl->createUser([ 'email' => '$user->email', 'username' => '$panelusername', 'password' => '$panelpassword', 'language' => 'en', 'root_admin' => false, 'first_name' => 'A', 'last_name' => 'user' ]); print_r($user);

When I try to create an account with that it gives me this error:
Fatal error: Uncaught HCGCloud\Pterodactyl\Exceptions\ValidationException: The given data failed to pass validation.

Error 500

Hi, i'm getting this error, what should be wrong?
PHP message: PHP Fatal error: Uncaught Error: Call to undefined method HCGCloud\Pterodactyl\Pterodactyl::createServer()

Get a server instance by external id string

Currently the library forces the serverEx method to provide an int as an external identifier, however pterodactyl does allow this value to be a string as well, there should be no reason for this type to be forced.

Filters on users not being applied

I'm trying to filter by an email using the query parameter at the paginate function:

...
->users
->paginate(1, [
    'filter' => [
        'email' => '[email protected]'
    ]
]);

As in src/Http.php line 88 the query parameter is passed as a payload and not as query parameter. This causes that the query parameters are not correctly sent to the api. The query parameters are for example needed in the filter mentioned above.

I will submit a PR to solve this behavior in the next hours. If you have any additional point for me please comment.

Egg 'docker_image' Blank

The docker_image variable of an Egg resource is blank. I found that renaming the variable to dockerImage fixed the issue.

No viable nodes for deployment

{"errors":[{"code":"NoViableNodeException","status":"400","detail":"No nodes satisfying the requirements specified for automatic deployment could be found."}]}

This is the error I get while trying to create a server. My code:

$server = $pterodactyl->createServer([ "name" => $name, "user" => $row["pterodactyl_userid"], "egg" => $egg_id, "docker_image" => $egg->dockerImage, "skip_scripts" => false, "environment" => [ "SERVER_AUTOUPDATE" => '1' ], "limits" => [ "memory" => $_POST['server_ram'], "swap" => 0, "disk" => $_POST['server_disk'], "io" => 500, "cpu" => $_POST['cpu'] * 100 ], "feature_limits" => [ "databases" => 1, "allocations" => 1 ], "startup" => $egg->startup, "description" => "An server made by the client page.", "deploy" => [ "locations" => [$location_id], "dedicated_ip" => false, "port_range" => [] ], "start_on_completion" => true ]);

The location id is valid and everything, it just doesn't want to create a server

Trying to create an user, gives an error.

Hi,,
So I am trying to create a new user.
This is the code that I'm using:
$pterodactyl = new \HCGCloud\Pterodactyl\Pterodactyl("KEY_REMOVED", "URL_REMOVED"); $password = randomPassword(); $user = $pterodactyl->createUser([ "external_id" => $id, "email" => $id.'@hattorius.com', "username" => $id, "first_name" => $id, "last_name" => $id, "language" => 'en', "password" => $password ]);

I get the following error ->

Fatal error: Uncaught HCGCloud\Pterodactyl\Exceptions\ValidationException: The given data failed to pass validation. in /home/admin/domains/URL_REMOVED/public_html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php:110 Stack trace: #0 /home/admin/domains/URL_REMOVED/public_html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(95): HCGCloud\Pterodactyl\Pterodactyl->handleRequestError(Object(GuzzleHttp\Psr7\Response)) #1 /home/admin/domains/URL_REMOVED/public_html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(33): HCGCloud\Pterodactyl\Pterodactyl->request('POST', 'api/application...', Array) #2 /home/admin/domains/URL_REMOVED/public_html/vendor/hcgcloud/pterodactyl-sdk/src/Actions/ManagesUsers.php(52): HCGCloud\Pterodactyl\Pterodactyl->post('api/application...', Array) #3 /home/admin/domains/URL_REMOVED/public_html/DO_NOT_TOUCH/index.php(156): HCGCloud\Pterodactyl\Pterodactyl->createUser(Array) #4 /home/admin/domains/URL_REMOVED/public_html/DO_NOT_TOUCH/index.php(181): buyservice('610603160301469 in /home/admin/domains/URL_REMOVED/public_html/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php on line 110

I've installed the SDK with composer. It went very smooth and no errors/warnings were created. Also, executing createUser() gives the error, making the connection doesn't.

I would very much appreciate the help! <3

Server create

Hi,

nice work. I played around with your sdk and can't create servers.
Uncaught HCGCloud\Pterodactyl\Exceptions\ValidationException: The given data failed to pass validation. in /var/www/testsite/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php:110

My testfile is the following:

require_once("vendor/autoload.php"); 
$pterodactyl = new \HCGCloud\Pterodactyl\Pterodactyl('xLm12Vhbroswc0CODE2Ds0oLrzrfAtODQoVaqWqYBWOcKDReotFv', 'http://127.0.0.1/');
$nest_id = 1;
$egg_id = 5;
$location_id = 1;
$egg = $pterodactyl->egg($nest_id, $egg_id); //get docker_image and startup directly from egg
$server = $pterodactyl->createServer([
    "external_id" => 11,
    "name" => "test",
    "user" => 1,
    "egg" => $egg_id,
    "pack" => 0,
    "docker_image" => $egg->dockerImage,
    "skip_scripts" => false,
    "environment" => [],
    "limits" => [
        "memory" => 2048,
        "swap" => 0,
        "disk" => 20000,
        "io" => 0,
        "cpu" => 100
    ],
    "feature_limits" => [
        "databases" => 0,
        "allocations" => 0
    ],
    "startup" => $egg->startup,
    "description" => "",
    "deploy" => [
        "locations" => [$location_id],
        "dedicated_ip" => false,
        "port_range" => []
    ],
    "start_on_completion" => true
]);
print_r($server);

My node is on 0.6.12.
I am able to create servers right in the panel.

Also I'm playing with your newly created node support, there also I got the same errors.

Hey there, Could I get some help?

So hi there, basically what I want to do while creating servers, is just print out the {"errors":[{"code":"NoViableAllocationException","status":"400","detail":"No allocations satisfying the requirements for automatic deployment were found."}]} and just that. How could I do that? For now I am using
` }catch(\HCGCloud\Pterodactyl\Exceptions\ValidationException $e){
print_r($e->errors());

}`

Curl Response says Cloudflare captcha loading

Hello I am using this SDK to send a power action to my server. I have made the php file and when I execute it from my ubuntu machine using php api.php it works fine. But when I upload the project to any web server and execute it from there, It gives me a cloudflare screen with a loading sign at the center. And at the top left corner there is "Please enable cookies". I am sorry I am very new to php so I am wondering if this is a problem with the web-hosting company or with my project.

[Note: If I use it for a different pterodactyl site, then both ubuntu machine and website host works perfectly. So I am guessing I have to somehow bypass the HCaptcha. Is there some way I can send HCaptcha accessibility cookie when sending the post request with your api?]

Fatal error

Hello,
when I use the sdk I get the following issue:

Fatal error: Uncaught Error: Call to undefined function HCGCloud\Pterodactyl\array_add() in /var/www/XXXX/XXXXXX.de/XX.XXXXX.de/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php:89 Stack trace: #0 /var/www/vhosts/XXXXXX.de/test.XXXXXX.de/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php(21): HCGCloud\Pterodactyl\Pterodactyl->request('GET', 'api/application...') #1 /var/www/vhosts/XXXXXX.de/test.XXXXXX.de/vendor/hcgcloud/pterodactyl-sdk/src/Actions/ManagesUsers.php(18): HCGCloud\Pterodactyl\Pterodactyl->get('api/application...') #2 /var/www/vhosts/XXXXXX.de/test.XXXXXX.de/test.php(4): HCGCloud\Pterodactyl\Pterodactyl->users() #3 {main} thrown in /var/www/vhosts/XXXXXX.de/test.XXXXXX.de/vendor/hcgcloud/pterodactyl-sdk/src/MakesHttpRequests.php on line 89

Can you help?

Blesta and Pterodactyl

I am using the newest Blesta build and the Pterodactyl Module from blesta.

I am getting this error: No allocations satisfying the requirements for automatic deployment were found.

I typed all the information. Yes checked the automated allocation in advanced config and the node.

i don't know what the problem is.

Internal Server Error

Hello, I have a problem with your API.
When I use it I get an internal server error.

require __DIR__.'/requests/api/vendor/autoload.php';
$pterodactyl = new \HCGCloud\Pterodactyl\Pterodactyl("XXXXXXXXXXXXX","https://mypanel.com");

    $user = $pterodactyl->createUser([
        "email" => '[email protected]',
        "username" => 'TestUser',
        "first_name" => 'Test',
        "last_name" => 'User',
        "language" => 'en',
        "password" => '123456'
    ]);

Can you help me ?
Thank you in advance

Best regards,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.