-
Notifications
You must be signed in to change notification settings - Fork 0
/
principal.php
62 lines (60 loc) · 2.25 KB
/
principal.php
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
<?php
$tema ='vacinacao';
$chaveAPI ='558873e9c6044919b3956c8510f9f85c' ;
$url ='https://newsapi.org/v2/everything?q='.$tema.'&qInTitle='.$tema.'&sortBy=relevancy&pageSize=7&apiKey='.$chaveAPI;
$response = file_get_contents($url);
$NewsData = json_decode($response);
// print_r($NewsData);
?>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php
$controle_ativo=2;
$controle_num_slide =0;
foreach ($NewsData->articles as $New)
{
if($controle_ativo==2){?>
<li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $controle_num_slide; ?>" class="active"></li>
<?php $controle_ativo=1;
}else{
$controle_num_slide++;
?>
<li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $controle_num_slide; ?>"></li>
<?php
}
}?>
</ol>
<div class="carousel-inner">
<?php
$controle_ativo=2;
foreach ($NewsData->articles as $New)
{
if($controle_ativo==2){?>
<div class="carousel-item active">
<img class="d-block w-100" src="<?php echo $New->urlToImage?>" alt="First slide">
<div class="carousel-caption d-none d-md-block">
<h5><?php echo $New->title?></h5>
<p><?php echo $New->description?></p>
</div>
</div>
<?php $controle_ativo=1;
}else{ ?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $New->urlToImage?>" alt="Second slide">
<div class="carousel-caption d-none d-md-block">
<h5 class="font-weight-bold"><?php echo $New->title?></h5>
<p class="font-weight-bold"><?php echo $New->description?></p>
</div>
</div><?php
}
}?>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>