[php]
<?php
$api_key = "YOUR_API_KEY";
$query = "example";
// 도메인 검색
$search_url = "https://domainr.p.mashape.com/v2/search?query=" . urlencode($query);
$search_options = [
"http" => [
"header" => "X-Mashape-Key: $api_key\r\nAccept: application/json\r\n",
"method" => "GET"
]
];
$search_context = stream_context_create($search_options);
$search_response = file_get_contents($search_url, false, $search_context);
$search_result = json_decode($search_response, true);
print_r($search_result);
// 도메인 상태 확인
$domain = "example.com";
$status_url = "https://domainr.p.mashape.com/v2/status?domain=" . urlencode($domain);
$status_options = [
"http" => [
"header" => "X-Mashape-Key: $api_key\r\nAccept: application/json\r\n",
"method" => "GET"
]
];
$status_context = stream_context_create($status_options);
$status_response = file_get_contents($status_url, false, $status_context);
$status_result = json_decode($status_response, true);
print_r($status_result);
?>
[js(node.js)]
const https = require('https');
const apiKey = 'YOUR_API_KEY';
const query = 'example';
// 도메인 검색
const searchUrl = `https://domainr.p.mashape.com/v2/search?query=${encodeURIComponent(query)}`;
const searchOptions = {
headers: {
'X-Mashape-Key': apiKey,
'Accept': 'application/json'
}
};
https.get(searchUrl, searchOptions, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
const searchResult = JSON.parse(data);
console.log(searchResult);
});
}).on('error', (e) => {
console.error(e);
});
// 도메인 상태 확인
const domain = 'example.com';
const statusUrl = `https://domainr.p.mashape.com/v2/status?domain=${encodeURIComponent(domain)}`;
const statusOptions = {
headers: {
'X-Mashape-Key': apiKey,
'Accept': 'application/json'
}
};
https.get(statusUrl, statusOptions, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
const statusResult = JSON.parse(data);
console.log(statusResult);
});
}).on('error', (e) => {
console.error(e);
});