<?php header('Content-type:application/json'); function get_collectpoint() { $params = array('username' => $_REQUEST['username'], 'user_pass' => $_REQUEST['password'], 'client_id' => $_REQUEST['id_client'], 'number' => $_REQUEST['nr_puncte'], 'radius' => $_REQUEST['radius'], 'address' => $_REQUEST['judet'] . ', ' . $_REQUEST['localitate'] . ', ' . $_REQUEST['adresa'], 'type' => 'eBOX'); $data = json_encode($params); $url = 'https://www.selfawb.ro/export_locatii_collect_point_integrat.php'; $c = curl_init($url); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($c); $header = curl_getinfo($c); curl_close($c); $output['message'] = $result; $output['status'] = $header['http_code']; return $output; } if ($_SERVER["REQUEST_METHOD"] == "POST" && $_SERVER["CONTENT_TYPE"] == "application/json") { function test() { $data = trim(file_get_contents("php://input")); $json = json_decode($data, true); if (is_array($json)) { $_REQUEST = $json + $_REQUEST; } $result = get_collectpoint(); $collect_point_lines = str_getcsv($result['message'], "\n"); $rows = array_map('str_getcsv', $collect_point_lines); $header = array_shift($rows); $csv = array(); foreach ($rows as $row) { $csv[] = array_combine($header, $row); } return $csv; } $points = test(); echo '<ul>'; foreach ($points as $point) { echo '<li>'; echo 'Adresa: ' . $point['Adresa'] . ' Localitate: ' . $point['Localitate'] . ' Distanta: ' . $point['Distanta'] . ' km'; echo '</li>'; } echo '</ul>'; } else { http_response_code(405); }