FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
astro-api-php-client/examples/advanced_usage.php at master · astrologyapi/astro-api-php-client · GitHub
astrologyapi
/
astro-api-php-client
Public
Notifications
You must be signed in to change notification settings
Fork
10
Star
11
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
astro-api-php-client
/
examples
/
advanced_usage.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
111 lines (91 loc) · 4.85 KB
Breadcrumbs
astro-api-php-client
/
examples
/
advanced_usage.php
Copy path
File metadata and controls
111 lines (91 loc) · 4.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
declare
(strict_types=
1
);
require_once
__DIR__
.
'
/../vendor/autoload.php
'
;
use
AstrologyAPI
\
Client
;
use
AstrologyAPI
\
Models
\
BirthData
;
use
AstrologyAPI
\
Models
\
PDFBranding
;
use
AstrologyAPI
\
Errors
\
PlanRestrictedError
;
use
AstrologyAPI
\
Errors
\
QuotaExceededError
;
use
AstrologyAPI
\
Errors
\
AstrologyAPIException
;
/**
* AstrologyAPI PHP SDK — Advanced Usage Examples
*
* Before running:
* export ASTROLOGYAPI_API_KEY="your-api-key"
* composer install
* php examples/advanced_usage.php
*/
$
client
= Client::
fromEnv
();
$
birth
=
new
BirthData
(
day:
15
, month:
8
, year:
1990
,
hour:
14
, min:
30
,
lat:
28.6139
, lon:
77.2090
, tzone:
5.5
,
);
// ── Vedic Matchmaking ─────────────────────────────────────────────────
// Male and female birth data are sent with m_ and f_ prefixes respectively.
$
male
=
new
BirthData
(day:
15
, month:
8
, year:
1990
, hour:
14
, min:
30
, lat:
28.6139
, lon:
77.2090
, tzone:
5.5
);
$
female
=
new
BirthData
(day:
20
, month:
3
, year:
1992
, hour:
10
, min:
15
, lat:
19.0760
, lon:
72.8777
, tzone:
5.5
);
echo
"
=== Matchmaking Report ===
\n"
;
$
match
=
$
client
->
vedic
()->
getMatchMakingReport
(
$
male
,
$
female
);
print_r
(
$
match
);
echo
"\n
=== Ashtakoot Points ===
\n"
;
$
ashtakoot
=
$
client
->
vedic
()->
getAshtakootPoints
(
$
male
,
$
female
);
print_r
(
$
ashtakoot
);
// ── Western Synastry ──────────────────────────────────────────────────
// Person 1 fields are prefixed p_, person 2 fields are prefixed s_.
echo
"\n
=== Synastry Horoscope ===
\n"
;
$
synastry
=
$
client
->
western
()->
getSynastry
(
$
male
,
$
female
);
print_r
(
$
synastry
);
// ── PDF Reports ───────────────────────────────────────────────────────
// All PDF methods return raw binary string. Write to file or stream to browser.
$
branding
=
new
PDFBranding
(
logoUrl:
'
https://example.com/logo.png
'
,
companyName:
'
My Astrology Business
'
,
domainUrl:
'
https://example.com
'
,
companyEmail:
'
hello@example.com
'
,
);
echo
"\n
=== Generating Basic Horoscope PDF ===
\n"
;
$
pdf
=
$
client
->
pdf
()->
vedic
->
getBasicHoroscope
(
$
birth
,
$
branding
, [
'
name
'
=>
'
Rahul
'
]);
file_put_contents
(
'
/tmp/horoscope.pdf
'
,
$
pdf
);
echo
"
Saved
"
.
strlen
(
$
pdf
) .
"
bytes to /tmp/horoscope.pdf
\n"
;
echo
"\n
=== Generating Match Making PDF ===
\n"
;
$
matchPdf
=
$
client
->
pdf
()->
vedic
->
getMatchMaking
(
$
male
,
$
female
,
$
branding
, [
'
name
'
=>
'
Rahul
'
,
'
partner_name
'
=>
'
Priya
'
,
]);
file_put_contents
(
'
/tmp/match_making.pdf
'
,
$
matchPdf
);
echo
"
Saved
"
.
strlen
(
$
matchPdf
) .
"
bytes to /tmp/match_making.pdf
\n"
;
echo
"\n
=== Generating Western Natal Chart PDF ===
\n"
;
$
natalPdf
=
$
client
->
pdf
()->
western
->
getNatalChart
(
$
birth
,
$
branding
);
file_put_contents
(
'
/tmp/natal_chart.pdf
'
,
$
natalPdf
);
echo
"
Saved
"
.
strlen
(
$
natalPdf
) .
"
bytes to /tmp/natal_chart.pdf
\n"
;
// ── Location Helpers ──────────────────────────────────────────────────
echo
"\n
=== Geo Details ===
\n"
;
$
geo
=
$
client
->
location
()->
getGeoDetails
(
'
New Delhi, India
'
, maxRows:
3
);
print_r
(
$
geo
);
// ── Horoscope Predictions ─────────────────────────────────────────────
echo
"\n
=== Daily Horoscope for Aries ===
\n"
;
$
horoscope
=
$
client
->
horoscopes
()->
getDaily
(
'
aries
'
);
print_r
(
$
horoscope
);
echo
"\n
=== Consolidated Daily Horoscope for Scorpio ===
\n"
;
$
consolidated
=
$
client
->
horoscopes
()->
getDailyConsolidated
(
'
scorpio
'
);
print_r
(
$
consolidated
);
// ── Tarot Reading ─────────────────────────────────────────────────────
echo
"\n
=== Daily Tarot Card ===
\n"
;
$
tarot
=
$
client
->
tarot
()->
getDailyCard
();
print_r
(
$
tarot
);
// ── Chinese Astrology ─────────────────────────────────────────────────
echo
"\n
=== Chinese Horoscope ===
\n"
;
$
chinese
=
$
client
->
chinese
()->
getChineseHoroscope
(
$
birth
);
print_r
(
$
chinese
);
// ── Error Handling ────────────────────────────────────────────────────
echo
"\n
=== Error Handling Demo ===
\n"
;
try
{
$
result
=
$
client
->
vedic
()->
getBirthDetails
(
$
birth
);
}
catch
(
QuotaExceededError
$
e
) {
echo
"
Quota exceeded (402):
{
$
e
->
getMessage
()}\n"
;
}
catch
(
PlanRestrictedError
$
e
) {
echo
"
Plan restriction (403):
{
$
e
->
getMessage
()}\n"
;
}
catch
(
AstrologyAPIException
$
e
) {
echo
"
API error (
{
$
e
->
getHttpCode
()}
):
{
$
e
->
getMessage
()}\n"
;
}
Back
|
FazBrowse Home
|
New Git URL