それで、デジタルオーシャンでドロップレットを起動およびシャットダウンする方法が必要です。独自のAPIがありますが、その方法がよくわかりません
基本的には自分のウェブサイトでボタンをクリックできるようにしたいのですが、サーバーが起動し、JSON レスポンスが表示されます。API の URL は https://api.digitalocean.com/droplets/?client_id=[your_client_id]&api_key=[your_api_key] です。
出力例は次のとおりです。
{ "status": "OK", "droplets": [ { "id": 100823, "name": "test222", "image_id": 420, "size_id":33, "region_id": 1, "backups_active" : false, "ip_address": "127.0.0.1", "locked": false, "status": "active" "created_at": "2013-01-01T09:30:00Z" } ] }
どんな助けでも大歓迎です
編集:これは、私が作業しようとしているコードです。
<html>
<head>
<link href="styles.css" rel="stylesheet" type="text/css" />
<title>Server Control Panel</title>
</head>
<body>
<input type="submit" value="Start!" name="submit" id="Startbutton" />
<input type="submit" value="Stop Server" name "submit2" id"Stopbutton" />
<?php
if (isset($_POST['submit'])) {
$request = 'https://api.digitalocean.com/droplets/377781/power_on/client_id=CLIENTIDGOESHERE&api_key=APIKEYGOESHERE';
$response = file_get_contents($request);
$jsonobj = json_decode($response);
echo($response);
}
?>
<?php
if (isset($_POST['Stopbutton'])) {
$request = 'https://api.digitalocean.com/droplets/377781/shutdown/client_id=CLIENTIDGOESHERE&api_key=APIKEYGOESHERE';
$response = file_get_contents($request);
$jsonobj = json_decode($response);
echo($response);
}
echo("</ul>");
?>
</form>
</body>
</html>