SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function get_shipping_cost($remitente,$destinatario,$precio,$cantidad,$peso,$volumen){
  2.  
  3.     if($cantidad == 1) $cod_servicio = 12;
  4.     else if($cantidad > 1) $cod_servicio = 3;
  5.     $json = '{
  6.        "ciudad_origen":'.$remitente.',
  7.        "ciudad_destino":'.$destinatario.',
  8.        "cod_formapago":4,
  9.        "cod_servicio":'.$cod_servicio.',
  10.        "num_unidades":'.$cantidad.',
  11.        "mpesoreal_k":'.$peso.',
  12.        "mpesovolumen_k":'.$volumen.',
  13.        "valor_declarado":'.$precio.',
  14.        "cod_regional_cta":1,
  15.        "cod_oficina_cta":1,
  16.        "cod_cuenta":30,
  17.        "numero_guia":""
  18.     }';
  19.     $data = $json;
  20.     $process = curl_init();
  21.     curl_setopt($process,CURLOPT_URL,$this->url);
  22.     curl_setopt($process, CURLOPT_USERPWD, $this->username . ":" . $this->password);
  23.     curl_setopt($process, CURLOPT_TIMEOUT, 30);
  24.     curl_setopt($process, CURLOPT_POST, 1);
  25.     curl_setopt($process, CURLOPT_POSTFIELDS, $data);
  26.     curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
  27.     curl_setopt($process, CURLOPT_FOLLOWLOCATION, true);
  28.     $return = curl_exec($process);
  29.     curl_close($process);
  30.     return json_decode($return,true);
  31.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top