Created
April 30, 2023 23:34
-
-
Save yasinkuyu/7c93a2a5219c507bd4dc56589f3e40a8 to your computer and use it in GitHub Desktop.
Create a subdomain on DigitalOcean without using Composer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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