(mt):API PHP Client
- This page was last modified on December 3, 2011, at 22:13.
From (mt) Community Wiki
This class covers all the functions of the Media Temple API v1.0 (beta) as published on 2/14/2011. Please notice that this is not an official Media Temple work.
For more informations, see the API Documentation.
The class is divided into two parts. The first covers the Services API, the second the Stats API.
Contents |
Download the client
You can download the PHP Client on GitHub.
How does it work?
Just instantiate the object passing your API Key and optionally your service ID:
$mt = new MtAPI('FbDgBldQMoKLwIXsBwq...', XXXXX); // Where XXXXX is an int
You can set your Service ID at anytime by calling the following method:
$mt->set_service_id(YYYYY); // Where YYYYY in an int
You can access some technical information with the following methods:
$url = $mt->servicesAPI(); // Return the URL of the Services API $url = $mt->statsAPI() // Return the URL of the Stats API $code = $mt->lastStatusCode(); // Return the last HTTP code (int) $call = $mt->lastAPICall(); // Return the last API URL called
You can also set some options:
$mt->format = 'json'; // Set response format to JSON or XML $mt->decode_json = FALSE; // If TRUE, results will be returned as a PHP Array $mt->wrap_root = FALSE; // Put results in a parent object if set to TRUE $mt->pretty_print = FALSE; // Indent results if set to TRUE
Services API
You can use all the following functions to interact with the Services API.
| Method | Description | Params | Require Service ID to be set |
|---|---|---|---|
| add_service() | Add a service to your account |
|
No |
| get_os_list() | Get available OS list | None | No |
| get_services_list() | Get a list of your services | None | No |
| get_services_ids() | Get the IDs of your services | None | No |
| get_service_details() | Get the details of one of your services | None | Yes |
| reboot_service() | Reboot your service | None | Yes |
| set_plesk_password() | Change your Plesk password |
|
Yes |
| set_root_password() | Change the root password of your service |
|
Yes |
| add_temp_disk() | Add temporary disk space to your service | None | Yes |
| flush_firewall() | Flush firewall rules of your service | None | Yes |
Stats API
You can use all the following functions to interact with the Stats API.
| Method | Description | Params | Require Service ID to be set |
|---|---|---|---|
| get_current_stats() | Get current stats of your service | None | Yes |
| get_range_stats() | Get stats of your service on a range of time |
|
Yes |
| get_predefined_range_stats() | Get stats of your service on a predefined range |
|
Yes |
| get_warnings() | Get the service's warnings | None | Yes |
| get_warnings_thresholds() | Get the different warning thresholds | None | Yes |
And that's it! Have fun with the API.