001.
<?php
002.
003.
004.
$current_lotto_name_space
= (isset(
$_REQUEST
[
's'
]))?
$_REQUEST
[
's'
]:
''
;
005.
$lotto_day
= (isset(
$_REQUEST
[
'lotto_day'
]))?
$_REQUEST
[
'lotto_day'
]:
''
;
006.
$lotto_number
= (isset(
$_REQUEST
[
'lotto_number'
]))?
$_REQUEST
[
'lotto_number'
]:
''
;
007.
008.
010.
$api_key
=
''
;
011.
012.
$header
=
array
(
013.
"Content-Type: application/json"
,
014.
"Accept: application/json"
,
015.
"X-API-KEY:"
.
$api_key
,
016.
);
017.
$ch
= curl_init(
$server_url
);
018.
curl_setopt(
$ch
, CURLOPT_SSL_VERIFYHOST, 0);
019.
curl_setopt(
$ch
, CURLOPT_SSL_VERIFYPEER, 0);
020.
curl_setopt(
$ch
, CURLOPT_POST, 0);
021.
curl_setopt(
$ch
, CURLOPT_RETURNTRANSFER, 1);
022.
curl_setopt(
$ch
, CURLOPT_FOLLOWLOCATION, 1);
023.
curl_setopt(
$ch
, CURLOPT_HTTPHEADER,
$header
);
024.
$result
= curl_exec(
$ch
);
025.
curl_close(
$ch
);
026.
$json
= json_decode(
$result
);
027.
$lotteryday
= (isset(
$json
->result))?
$json
->result:
array
();
028.
029.
030.
032.
$header
=
array
(
033.
"Content-Type: application/json"
,
034.
"Accept: application/json"
,
035.
"X-API-KEY:"
.
$api_key
,
036.
);
037.
$ch
= curl_init(
$server_url
);
038.
curl_setopt(
$ch
, CURLOPT_SSL_VERIFYHOST, 0);
039.
curl_setopt(
$ch
, CURLOPT_SSL_VERIFYPEER, 0);
040.
curl_setopt(
$ch
, CURLOPT_POST, 0);
041.
curl_setopt(
$ch
, CURLOPT_RETURNTRANSFER, 1);
042.
curl_setopt(
$ch
, CURLOPT_FOLLOWLOCATION, 1);
043.
curl_setopt(
$ch
, CURLOPT_HTTPHEADER,
$header
);
044.
$result
= curl_exec(
$ch
);
045.
curl_close(
$ch
);
046.
$json
= json_decode(
$result
);
047.
$lotto
= (isset(
$json
->result))?
$json
->result:
array
();
048.
049.
050.
051.
if
(isset(
$lotto_day
) && isset(
$lotto_number
)){
053.
$header
=
array
(
054.
"Content-Type: application/json"
,
055.
"Accept: application/json"
,
056.
"X-API-KEY:"
.
$api_key
,
057.
);
058.
$ch
= curl_init(
$server_url
);
059.
curl_setopt(
$ch
, CURLOPT_SSL_VERIFYHOST, 0);
060.
curl_setopt(
$ch
, CURLOPT_SSL_VERIFYPEER, 0);
061.
curl_setopt(
$ch
, CURLOPT_POST, 0);
062.
curl_setopt(
$ch
, CURLOPT_RETURNTRANSFER, 1);
063.
curl_setopt(
$ch
, CURLOPT_FOLLOWLOCATION, 1);
064.
curl_setopt(
$ch
, CURLOPT_HTTPHEADER,
$header
);
065.
$result
= curl_exec(
$ch
);
066.
curl_close(
$ch
);
067.
$winner
=
$result
;
068.
}
069.
070.
071.
072.
?>
073.
<!DOCTYPE html>
074.
<html lang=
"en"
>
075.
<head>
076.
<title>Example Thai Lottery API</title>
077.
079.
<link rel=
"stylesheet"
href=
"assets/plugins/bootstrap/css/bootstrap.min.css"
>
080.
<link id=
"theme-style"
rel=
"stylesheet"
href=
"assets/css/styles.css"
>
081.
</head>
082.
083.
084.
<body
class
=
"landing-page"
>
085.
<div
class
=
"page-wrapper"
>
086.
087.
088.
<section
class
=
"cards-section text-center"
>
089.
<div
class
=
"container-fluid"
>
090.
<div
class
=
"row"
>
091.
092.
<?php
093.
foreach
(
$lotto
as
$row
){
094.
$id
=
$row
->id;
095.
$name
=
$row
->name;
096.
$amount
=
$row
->amount;
097.
$reward
=
$row
->reward;
098.
$number
=
$row
->number;
099.
?>
100.
<div
class
=
"col-12 p-3"
>
101.
<div
class
=
"card"
>
102.
<div
class
=
"row"
>
103.
<div
class
=
"col-12 item item-green"
>
104.
<div
class
=
"item-inner"
>
105.
<div
class
=
"soc-header box-facebook p-3"
>
106.
<h3
class
=
"title"
><?=
$name
; ?> มี <?=
$amount
; ?> รางวัล</h3>
107.
<span
class
=
"text-muted"
>รางวัลละ <?=number_format(
$reward
,0); ?> บาท</span>
108.
</div>
109.
<div
class
=
"row soc-content "
>
110.
<?php
if
(!
is_array
(
$number
)){ ?>
111.
<div
class
=
"col b-r text-center"
>
112.
<h3
class
=
"intro"
><?php
echo
$number
; ?></h5>
113.
</div>
114.
<?php }
else
{ ?>
115.
<?php
for
(
$i
= 0;
$i
<
count
(
$number
);
$i
++){ ?>
116.
<div
class
=
"col b-r text-center"
>
117.
<h3
class
=
"intro"
><?php
echo
$number
[
$i
]; ?></h5>
118.
</div>
119.
<?php }} ?>
120.
</div>
121.
</div>
122.
</div>
123.
</div>
124.
</div>
125.
</div>
126.
127.
<?php } ?>
128.
</div>
129.
</div>
130.
131.
132.
</section>
133.
</div>
134.
135.
136.
<script type=
"text/javascript"
src=
"assets/plugins/jquery-3.4.1.min.js"
></script>
137.
<script type=
"text/javascript"
src=
"assets/plugins/bootstrap/js/bootstrap.min.js"
></script>
138.
139.
</body>
140.
</html>