function jne($dari, $ke, $kg, $user_agent) { $json_dari = "http://www.jne.co.id/server/server_city_from.php?term={$dari}"; $json_daric = file_get_contents($json_dari); $hasil_dari = json_decode($json_daric); $json_ke = "http://www.jne.co.id/server/server_city.php?term={$ke}"; $json_kec = file_get_contents($json_ke); $hasil_ke = json_decode($json_kec); if ($hasil_dari == null || $hasil_ke == null) { return errorcoy(); } else { $daric = $hasil_dari[0]->code; $darib = $hasil_dari[0]->label; $kec = $hasil_ke[0]->code; $keb = $hasil_ke[0]->label; $ch = curl_init(); $url = "http://www.jne.co.id/getDetailFare.php"; $post = "origin={$daric}&dest={$kec}&weight={$kg}&originlabel={$darib}&destlabel={$keb}"; curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $site = curl_exec($ch); return $site; } }
function kota($dari, $ke, $kg, $user_agent) { $json_dari = "http://www.jne.co.id/server/server_city_from.php?term={$dari}"; $json_daric = file_get_contents($json_dari); $hasil_dari = json_decode($json_daric); $json_ke = "http://www.jne.co.id/server/server_city.php?term={$ke}"; $json_kec = file_get_contents($json_ke); $hasil_ke = json_decode($json_kec); if ($hasil_dari == null || $hasil_ke == null) { return errorcoy(); } else { $daric = $hasil_dari[0]->code; $darib = $hasil_dari[0]->label; $kec = $hasil_ke[0]->code; $keb = $hasil_ke[0]->label; return jne($daric, $kec, $darib, $keb, $kg, $user_agent); } }