<?php

function call_emag()
{
    $emag = 'https://sapi.emag.ro/products/EPLRNBBBM/bundle-pac-by-pnk?source_id=7&shop_type=default';
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($post, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_URL, $emag);
    curl_setopt($curl, CURLOPT_REFERER, $emag);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    $str = curl_exec($curl);
    var_dump($str);
    exit;
    $output = json_encode($str);
}
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_emag();
    echo $output;
}