<?php
$no_va = 0;
$blog_imgs = array(
'<img src="assets/global/images/pDx6CXfol13SQ2gJkMKc.jpg" alt=""/>',
'<img src="assets/global/images/AorQSrc6JQ9imJ9dNqCL.jpg" alt=""/>',
'<img src="assets/global/images/fyPoqgPqQGspt8cfbFqG.jpg" alt=""/>
');

$curl = curl_init();

curl_setopt_array($curl, [
	CURLOPT_URL => "https://cryptoinfo.p.rapidapi.com/api/private/latest_news/rapid_api/news/5",
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_ENCODING => "",
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 30,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => "GET",
	CURLOPT_HTTPHEADER => [
		"Content-Type: application/json",
		"X-RapidAPI-Host: cryptoinfo.p.rapidapi.com",
		"X-RapidAPI-Key: f3702d5d04msh895fd5a02882ebap10eca4jsn42720e88930a"
	],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err != 0) { ?>
	<div class="col-xl-4 col-lg-6 col-sm-12">
<div class=single-blog data-aos=fade-down data-aos-duration=1000>

<div class=content>


<div class=des>
<p> No news at this time. </p>
</div>

</div>
</div>
</div>
<?php } else {
	 $rsp = (json_decode($response));
	 $news_length = count($rsp)-2;
	 while($news_length >0){
		 $no_va= $no_va+1;
		  $blog_date_time =($rsp[$news_length]->meta->post_time);
		  
		  
		  $header = ($rsp[$news_length]->data->en->header);
		  $content = ($rsp[$news_length]->data->en->content);
		  $sub_header = ($rsp[$news_length]->data->en->subheader);
		  $sub_header = ($rsp[$news_length]->data->en->subheader);
		  $sub_header = ($rsp[$news_length]->data->en->subheader);
		  
		  $blog_date=date_create("$blog_date_time");
// 	// echo $sub_header;
	sleep(2);
?>
		<div class="col-xl-4 col-lg-6 col-sm-12">
<div class=single-blog data-aos=fade-down data-aos-duration=1000>
<div class=thumb>
	<?php echo $blog_imgs[$no_va-1]; ?>
</div>
<div class=content>
<div class=meta>
<div class=date><?php echo date_format($blog_date,"d F Y"); ?></div>
</div>
<div class=title>
<h3><a href="blog/index.php?header=<?php echo $header; ?>&subheader=<?php echo $sub_header; ?>&no=<?php echo $no_va; ?>&content=<?php echo $content; ?>"><?php echo $header; ?></a></h3>
</div>
<div class=des>
<p> <?php echo $sub_header; ?> </p>
</div>
<div class=link>
<a href="blog/index.php?header=<?php echo $header; ?>&subheader=<?php echo $sub_header; ?>&no=<?php echo $no_va; ?>&content=<?php echo $content; ?>">Continue Reading</a>
</div>
</div>
</div>
</div>

<?php 	
$news_length--;	 
	 }
	 
}	


// $date=date_create("2013-03-15");
// echo date_format($date,"d F Y");

?>

