Skip to content

Instantly share code, notes, and snippets.

@yasinkuyu
Created April 30, 2023 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasinkuyu/7c93a2a5219c507bd4dc56589f3e40a8 to your computer and use it in GitHub Desktop.
Save yasinkuyu/7c93a2a5219c507bd4dc56589f3e40a8 to your computer and use it in GitHub Desktop.
Create a subdomain on DigitalOcean without using Composer
<?php
$data = array(
"type" => "A",
"name" => "SUBDOMAIN",
"data" => "188.*****", // your ip address
"ttl" => 1800
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.digitalocean.com/v2/domains/YOURDOMAIN.COM/records");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$headers = array(
"Content-Type: application/json",
"Authorization: Bearer dop_v1_3b374f34******" // your api key
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result, true);
print_r($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment