ตัวอย่างโค้ด PHP สำหรับ API Numerology ของ Dakidarts¶
ตัวอย่างเหล่านี้แสดงวิธีการเรียกใช้จุดปลาย Core, Karmic, Cycles, และ Horoscope โดยใช้ PHP และคีย์ API Numerology โดยตรง
การตั้งค่า¶
<?php
$headers = [
"X-API-Key: YOUR_API_KEY",
"Content-Type: application/json"
];
function sendGetRequest($url, $params = []) {
global $headers;
$query = http_build_query($params);
$ch = curl_init("$url?$query");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
function sendPostRequest($url, $payload = []) {
global $headers;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
?>
ตัวอย่าง 1: จำนวนบุคลิกภาพ (Attitude Number)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/attitude_number";
$params = ["birth_day" => "14", "birth_month" => "3"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 2: จำนวนความท้าทาย (Challenge Number)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/challenge_number/post";
$payload = ["birth_year" => 1990, "birth_month" => 5, "birth_day" => 15];
$response = sendPostRequest($url, $payload);
print_r($response);
?>
ตัวอย่าง 3: หนี้กรรม (Karmic Debt)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/karmic_debt";
$params = ["birth_year" => "2023", "birth_month" => "6", "birth_day" => "28"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 4: บทเรียนจากกรรม (Karmic Lessons)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/karmic_lessons";
$params = ["full_name" => "John Doe Smith"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 5: จำนวนเส้นทางชีวิต (Life Path Number)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/life_path";
$params = ["birth_year" => "1990", "birth_month" => "5", "birth_day" => "12"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 6: จำนวนบุคลิกภาพ (Personality Number)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/personality_number/post";
$payload = ["first_name" => "John", "middle_name" => "Robert", "last_name" => "Doe"];
$response = sendPostRequest($url, $payload);
print_r($response);
?>
ตัวอย่าง 7: จำนวนชะตากรรม (Destiny Number)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/destiny_number";
$params = ["first_name" => "John", "middle_name" => "Doe", "last_name" => "Smith"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 8: จำนวนความปรารถนาในใจ (Heart Desire Number)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/heart_desire";
$params = ["first_name" => "John", "middle_name" => "Robert", "last_name" => "Doe"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 9: ปีส่วนตัว (Personal Year)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/personal_year";
$params = ["prediction_year" => "2023", "birth_month" => "12", "birth_day" => "3"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 10: การอ่านจากบรรพบุรุษ (Ancestor Reading)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/ancestor-reading";
$params = ["family_name" => "Etuge"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 11: ระดับการแสดงออก (Planes Of Expression)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/planes-of-expression";
$payload = ["fullname" => "Jesus Christ"];
$response = sendPostRequest($url, $payload);
print_r($response);
?>
ตัวอย่าง 12: โหรวันนี้ (Today Horoscope)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/horoscope/today";
$params = ["dob" => "2002-02-22"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 13: โหรประจำอาชีพวันนี้ (Today Career Horoscope)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/horoscope/career/today";
$payload = ["dob" => "1995-08-20"];
$response = sendPostRequest($url, $payload);
print_r($response);
?>
ตัวอย่าง 14: โหรประจำสุขภาพวันนี้ (Today Health Horoscope)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/horoscope/health/today";
$params = ["dob" => "1995-08-20"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 15: โหรประจำวันตามดาวเคราะห์ (Planetary Daily Horoscope)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/horoscope/planetary/daily";
$params = ["dob" => "1990-01-01", "day" => "today"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 16: วงจรแห่งความเป็นจริง (Essence Cycle)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/essence-cycle";
$params = ["full_name" => "Alexander Graham Bell", "dob" => "1847-03-03", "start_year" => "1847"];
$response = sendGetRequest($url, $params);
print_r($response);
?>
ตัวอย่าง 17: การเคลื่อนที่ของดาวเคราะห์ (Transits)¶
<?php
$url = "https://api.numerologyapi.com/api/v1/transits";
$payload = ["full_name" => "Alexander Graham Bell", "dob" => "1847-03-03"];
$response = sendPostRequest($url, $payload);
print_r($response);
?>
!!! หมายเหตุ ทุกจุดปลาย (endpoints) รองรับทั้งวิธีการ GET และ POST* (เมื่อเกี่ยวข้อง) * แทนที่ "YOUR_API_KEY" ด้วยคีย์ที่ถูกต้องของคุณ * ใช้ params สำหรับคำขอ GET และ payload/json สำหรับคำขอ POST