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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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 :)
@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.
–
stream_context_create
http://php.net/manual/en/function.stream-context-create.php
stream_get_contents
http://php.net/manual/en/function.stream-get-contents.php
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.