<?php if($dataGOI['airline'] == null) echo "Обновление"; else echo "<img width='100' height='40' alt='авиакомпания на рейс Москва — Гоа' src='//pics.avs.io/100/40/{$dataGOI['airline']}.jpg' class='lazyload air'>" ?>
https://avia-avia.ru/Test/index3.php
<?php
if (isset($data1['data']) && is_array($data1['data']))
{
foreach ($data1['data'] as $key => $dataGOI){
?>
echo $replace_value('departure_at',
departure_at":"2021-07-30T01:20:00+03:00"
а ее нужн сократить до дня. Не выводится ни дата ни цена, ни второй CH2 к сожалению( https://avia-avia.ru/Test/index3.php
<?php // create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();
// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "https://*****/aviasales/v3/prices_for_dates?origin=MOW&destination=LED&token=*****&departure_at=" . date('Y-m-d') );
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_URL, "******/v3/prices_for_dates?origin=MOW&destination=AER&token=******&departure_at=" . date('Y-m-d') );
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
//create the multiple cURL handle
$mh = curl_multi_init();
//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
//execute the multi handle
do {
$status = curl_multi_exec($mh, $active);
if ($active) {
curl_multi_select($mh);
}
} while ($active && $status == CURLM_OK);
$data1 = curl_multi_getcontent($ch1);
$data2 = curl_multi_getcontent($ch2);
$data1 = json_decode($data1, true);
$data2 = json_decode($data2, true);
//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);?>
<div class="table-responsive" style="overflow-x:hidden;background: var(--responsiv-color)!important; display: flex; flex-direction: column; width: 100%;margin-left: auto; margin-right: auto; list-style-type: none;overflow-y:hidden;">
<?php
if (isset($data1['data']) && is_array($data1['data']))
{
foreach ($data1['data'] as $key => $dataGOI){
?>
<ul class="ticket">
<li class="tickets_name"><p style="color:black;">Москва — Гоа</p> <span class="tickets_span">Рейс: <?=$dataGOI['flight_number'] ?> MOW — GOI</span></li>
<li class="li"><p><?php if($dataGOI['airline'] == null) echo "Обновление"; else echo "<img width='100' height='40' alt='авиакомпания на рейс Москва — Гоа' src='//pics.avs.io/100/40/{$dataGOI['airline']}.jpg' class='lazyload air'>" ?></p><span class="tickets_span"> Количество пересадок: <?= $dataGOI['transfers'] > 0 ? $dataGOI['transfers'] : "<span style='color:red'>Без пересадок</span>" ?></span></li>
<li class="li_span"><p style="color:black;"><?php echo $replace_value('departure_at', substr($dataGOI['departure_at'], 0, 10)); ?></p><span style="font-size: 13px!important; font-weight: 400; color: #4e5965!important; font-weight: 300;">Туда</span></li>
<a class="tickets_link" rel="nofollow" rel="noopener" role="button" alt="авиабилеты Москва <?php echo $replace_value('destination', $key); ?>" title="Москва <?php echo $replace_value('destination', $key); ?>" href="https://site.ru/flights/?origin_iata=MOW&destination_iata=<?=$dataGOI['destination'] ?>&depart_date=<?=substr($dataGOI['departure_at'], 0, 10) ?>&marker=87111&with_request=true&search_id=<?=$dataGOI['search_id']?>&signature=<?=$dataGOI['signature']?>"><li>Билеты от <?php echo $replace_value('price', $dataGOI['price']); ?> р. </li></a>
</ul></div>
<?php
}
}
?>
<?php // create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();
// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "https://********v3/prices_for_dates?origin=MOW&destination=LED&token=********&departure_at=" . date('Y-m-d') );
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_URL, "******/v3/prices_for_dates?origin=MOW&destination=AER&token=********&departure_at=" . date('Y-m-d') );
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
//create the multiple cURL handle
$mh = curl_multi_init();
//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
//execute the multi handle
do {
$status = curl_multi_exec($mh, $active);
if ($active) {
curl_multi_select($mh);
}
} while ($active && $status == CURLM_OK);
$data1 = curl_multi_getcontent($ch1);
print "RESPONSE1: $data1<br><br>";
$data2 = curl_multi_getcontent($ch2);
print "RESPONSE2: $data2<br><br>";
$data1 = json_decode($data1, true);
print "DATA1: ";
var_dump($data1);
$data2 = json_decode($data2, true);
print "DATA2: ";
var_dump($data2);
//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);?>
<div class="table-responsive" style="overflow-x:hidden;background: var(--responsiv-color)!important; display: flex; flex-direction: column; width: 100%;margin-left: auto; margin-right: auto; list-style-type: none;overflow-y:hidden;">
<?php
if (isset($mh['data']) && is_array($mh['data']))
{
foreach ($mh['data'] as $key => $dataGOI){
?>
<ul class="ticket">
<li class="tickets_name"><p style="color:black;">Москва — Гоа</p> <span class="tickets_span">Рейс: <?=$dataGOI['flight_number'] ?> MOW — GOI</span></li>
<li class="li"><p><?php if($dataGOI['airline'] == null) echo "Обновление"; else echo "<img width='100' height='50' alt='авиакомпания на рейс Москва — Гоа' src='*****/100/40/{$dataGOI['airline']}.jpg' class='lazyload air'>" ?></p><span class="tickets_span"> Количество пересадок: <?= $dataGOI['transfers'] > 0 ? $dataGOI['transfers'] : "<span style='color:red'>Без пересадок</span>" ?></span></li>
<li class="li_span"><p style="color:black;"><?php echo $replace_value('departure_at', substr($dataGOI['departure_at'], 0, 10)); ?></p><span style="font-size: 13px!important; font-weight: 400; color: #4e5965!important; font-weight: 300;">Туда</span></li>
<a class="tickets_link" rel="nofollow" rel="noopener" role="button" alt="авиабилеты Москва <?php echo $replace_value('destination', $key); ?>" title="Москва <?php echo $replace_value('destination', $key); ?>" href="https://site.ru/flights/?origin_iata=MOW&destination_iata=<?=$dataGOI['destination'] ?>&depart_date=<?=substr($dataGOI['departure_at'], 0, 10) ?>&marker=87111&with_request=true&search_id=<?=$dataGOI['search_id']?>&signature=<?=$dataGOI['signature']?>"><li>Билеты от <?php echo $replace_value('price', $dataGOI['price']); ?> р. </li></a>
</ul></div>
<?php
}
}
?>
RESPONSE1: {"success":true,"data":[{"origin":"MOW","destination":"LED","origin_airport":"SVO","destination_airport":"LED","price":6749,"airline":"SU","flight_number":"34","departure_at":"2021-07-28T23:15:00+03:00","search_id":"479f6cf7-c04d-4ade-a38e-3e1398f32a2c","signature":"584b66d0c8fd67c42602eb68f24945c7","transfers":0,"return_transfers":0,"duration":85}],"currency":"rub"}
RESPONSE2: {"success":true,"data":[{"origin":"MOW","destination":"AER","origin_airport":"DME","destination_airport":"AER","price":3498,"airline":"S7","flight_number":"2051","departure_at":"2021-07-28T23:55:00+03:00","search_id":"de8d2646-a703-4cf7-a506-a00575b5c5dd","signature":"fbc702bd796ae2a39c7e0837c4306a1c","transfers":0,"return_transfers":0,"duration":145}],"currency":"rub"}
DATA1: array(3) { ["success"]=> bool(true) ["data"]=> array(1) { [0]=> array(13) { ["origin"]=> string(3) "MOW" ["destination"]=> string(3) "LED" ["origin_airport"]=> string(3) "SVO" ["destination_airport"]=> string(3) "LED" ["price"]=> int(6749) ["airline"]=> string(2) "SU" ["flight_number"]=> string(2) "34" ["departure_at"]=> string(25) "2021-07-28T23:15:00+03:00" ["search_id"]=> string(36) "479f6cf7-c04d-4ade-a38e-3e1398f32a2c" ["signature"]=> string(32) "584b66d0c8fd67c42602eb68f24945c7" ["transfers"]=> int(0) ["return_transfers"]=> int(0) ["duration"]=> int(85) } } ["currency"]=> string(3) "rub" } DATA2: array(3) { ["success"]=> bool(true) ["data"]=> array(1) { [0]=> array(13) { ["origin"]=> string(3) "MOW" ["destination"]=> string(3) "AER" ["origin_airport"]=> string(3) "DME" ["destination_airport"]=> string(3) "AER" ["price"]=> int(3498) ["airline"]=> string(2) "S7" ["flight_number"]=> string(4) "2051" ["departure_at"]=> string(25) "2021-07-28T23:55:00+03:00" ["search_id"]=> string(36) "de8d2646-a703-4cf7-a506-a00575b5c5dd" ["signature"]=> string(32) "fbc702bd796ae2a39c7e0837c4306a1c" ["transfers"]=> int(0) ["return_transfers"]=> int(0) ["duration"]=> int(145) } } ["currency"]=> string(3) "rub" }
Алгоритм такой.
Фильтра у объекта с ID=ONE нет, нажал кнопку, объекту с id(One) ставиться фильтр grayscale(100%), повторное нажатие ID(one) уже без фильтра