new velov api

This commit is contained in:
Adrian Amaglio 2018-06-12 17:32:43 +02:00
parent 886283aa78
commit 9699037335
2 changed files with 10 additions and 17 deletions

View File

@ -14,20 +14,13 @@ $SEND_BUTTON = [
/* Fetching velov API in an associative array. This form is easier to use as keys are ids */
$data =
json_decode(
file_get_contents(
'https://velov.grandlyon.com/fr/les-stations.html?type=777&tx_glstationsvelov_pi1%5Baction%5D=listOfVelovWidthInfoStation&tx_glstationsvelov_pi1%5Bcontroller%5D=StationVelov',
false,
stream_context_create([
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query([])
]
])
file_get_contents('https://api.jcdecaux.com/vls/v1/stations?apiKey=frifk0jbxfefqqniqez09tw4jvk37wyf823b5j1i&contract=lyon',
false
),
true
);
/* Check if a filter is enabled */
if(isset($_GET['filter'])){
@ -54,16 +47,16 @@ if(isset($_GET['filter'])){
<tr><th>Sélectionner</th><th>Nom</th><th>Vélos</th><th>Places Libres</th></tr>
<?php
foreach ($data as $key => $station){
if ( ! $filter || isset($_GET[$key])){
if ( ! $filter || isset($_GET[$station['number']])){
echo '<tr>
<td>
<input type="checkbox" name="',$key,'" ',(isset($_GET[$key]) ? 'checked="checked"' : ''),' />
<input type="checkbox" name="',$station['number'],'" ',(isset($_GET[$station['number']]) ? 'checked="checked"' : ''),' />
</td>
<td class="', ($station['open'] == 1 && $station['obsolete'] == 0 ? 'success' : 'danger' ) ,'" >'
<td class="', ($station['status'] == 'OPEN' ? 'success' : 'danger' ) ,'" >'
,$station['name'],
'</td>
<td>',$station['AB'], '</td>
<td>', $station['ABS'], '</td>
<td>',$station['available_bikes'], '</td>
<td>', $station['available_bike_stands'], '</td>
</tr>';
}
}

View File

@ -3,8 +3,8 @@ html{
color:white;
}
.success{
color:green;
color: #18f218;
}
.danger{
color: red;
color: #fb2d2d;
}