File "vivre.php"
Full path: /home/kosmetik/public_html/api/price_hunt/vivre.php
File
size: 1.1 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
header('Content-type:application/json');
function call_vivre()
{
$test = file_get_contents('https://api.vivre.eu/mobile/v2/product?source=site&lang=ro&id=' . $_REQUEST['id_produs'] . '&sqs=ijce23sx654');
$data = trim($test);
$json = json_encode($data, true);
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_SERVER["CONTENT_TYPE"] == "application/json") {
$data = trim(file_get_contents("php://input"));
$json = json_decode($data, true);
if (is_array($json)) {
$_REQUEST = $json + $_REQUEST;
}
$output = call_vivre();
$ss = json_decode($output);
$product_data = $ss->dataLayer;
foreach ($product_data as $product) {
foreach ($product as $key => $value) {
if ($key == 'name') {
$name = $value;
}
if ($key == 'new_price') {
$pret_nou = $value;
}
if ($key == 'old_price') {
$pret_vechi = $value;
}
}
}
$ex = array('nume_produs' => $name, 'pret_vechi' => $pret_vechi, 'pret_nou' => $pret_nou);
print_r($ex);
}