PHP
para requests sem polilinha
$url = 'https://api.qualp.com.br/rotas/v4';
$data = [
"locations" => [
'Ponta Grossa pr',
'Curitiba pr',
],
"config" => [
"vehicle" =>[
"type"=> "truck",
"axis" => "all"
],
"freight_table" => [
"category" => "all",
"freight_load" => "all",
"axis" => "all"
],
"route" => [
"optimized_route" => false,
"calculate_return" => false
],
"private_places" => [
"max_distance_from_location_to_route" => 1000,
"categories" => true,
"areas" => true,
"contacts" => true,
"products" => true,
"services" => true
]
],
"show" => [
"polyline" => false,
"simplified_polyline" => true,
"private_places" => false,
"static_image" => true,
"freight_table" => true,
"link_to_qualp" => true,
"tolls" => true
],
"format" => "json",
"exception_key" => ""
];
$curl = curl_init();
$data = urlencode(json_encode($data));
$endpoint = "{$url}?json={$data}";
curl_setopt_array($curl, array(
CURLOPT_URL => $endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Access-Token: SEU-TOKEN',
'Content-Type: application/json',
'Accept: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
PHP
para requests com polilinhaEste request deve ser feito via POST
obrigatoriamente.
$url = 'https://api.qualp.com.br/rotas/v4';
$polyline = "Sua polilinha";
$data = [
"polyline" => [
"string" => $polyline,
"precision" => 6,
],
"config" => [
"vehicle" =>[
"type"=> "truck",
"axis" => "all"
],
"freight_table" => [
"category" => "all",
"freight_load" => "granel_solido",
"axis" => "2"
],
"route" => [
"optimized_route" => false,
"calculate_return" => false
],
"private_places" => [
"max_distance_from_location_to_route" => 1000,
"categories" => true,
"areas" => true,
"contacts" => true,
"products" => true,
"services" => true
]
],
"show" => [
"polyline" => false,
"simplified_polyline" => true,
"private_places" => false,
"static_image" => true,
"freight_table" => true,
"link_to_qualp" => true,
"tolls" => true
],
"format" => "json",
"exception_key" => ""
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.qualp.com.br/rotas/v4',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
'Access-Token: SEU-TOKEN',
'Content-Type: application/json',
'Accept: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;