AutoCreate A Droplet with a php script?

November 12, 2015 625 views
Apache PHP Ubuntu

I would like to create a script that automatically creates a droplet.
This script will have to be on my site.
For example, when a customer orders a VPS from my site via a script, the droplet will be created and the data to access it sends them by mail.
Is it possible?

2 Answers

@Dennys - Absolutely! You can use one of the available third-party libraries, such as the one linked to by @ryanpq (which is a very nice library -- I've used it myself), or you can implement your own custom wrapper around DigitalOcean's API (I've done this as well).

With PHP, you have a few options if you choose to go the custom route over using an existing third-party library. The most common method that I've seen implemented is by using PHP's cURL library (link) -- you could also use PHP's Streams library (link).

Ultimately, I'd go with Streams over cURL, though that's my personal preference. There's numerous options for cURL and while I've used it in the past to access API's, Streams seems to be a much cleaner way of doing the same thing.




This is absolutely possible. We provide an API to most control panel features. While we do not maintain an official PHP library for our API a great third party library is available here.

These links will provide some additional information on the API.

If you have any questions or run into any problems let me know :)

by Mitchell Anicas
In this tutorial, we will teach you how to get started with the DigitalOcean API v2.0. We will show you how to generate personal access tokens, which will be used for authentication, and show a few examples of how the API can be used. The DigitalOcean API allows you to manage Droplets and resources within the DigitalOcean cloud in a simple, programmatic way using conventional HTTP requests.
Have another answer? Share your knowledge.