- Beranda
- Website, Webmaster, Webdeveloper
Begini cara cURL ongkir JNE dan TIKI menggunakan PHP
...
![bachors](https://s.kaskus.id/user/avatar/default.png)
![Avatar border](https://s.kaskus.id/images/avatarborder/1.gif)
TS
bachors
Begini cara cURL ongkir JNE dan TIKI menggunakan PHP
Simple fungtion untuk mengambil ongkir Tiki dan JNE langsung melalui web tiki-online.com dan jne.co.id dengan menggunakan PHP cURL dan librarie simple html dom.
1. cURL ongkir TIKI
2. cURL ongkir JNE
Cara memanggil fungsi.y
Untuk demonya bisa lihat disini
1. cURL ongkir TIKI
Code:
function tiki($dari,$ke,$kg,$user_agent){
$ch = curl_init();
$url="http://www.tiki-online.com/?cat=KgfdshfF7788KHfskF";
$post = "&get_ori=$dari&get_des=$ke&get_wg=$kg&submit=Check";
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 ongkos_tiki($site);
}
function ongkos_tiki($site){
// include simple html dom
require("lib/simple_html_dom.php");
$html = str_get_html($site);
$table = $html->find('table[cellpadding=4]',0);
return $table;
}
2. cURL ongkir JNE
Code:
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);
$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;
}
Cara memanggil fungsi.y
Code:
$dari = 'bandung';
$ke = 'surabaya';
$berat = 4;
$user_agent = "Googlebot/2.1 (http://www.googlebot.com/bot.html)";
// menampilkan ongkir TIKI
echo tiki($dari,$ke,$berat,$user_agent);
// menampilkan ongkir JNE
echo jne($dari,$ke,$berat,$user_agent);
Untuk demonya bisa lihat disini
![Betty (S) emoticon-Betty (S)](https://s.kaskus.id/images/smilies/mahos.gif)
0
5.1K
14
![Guest](https://s.kaskus.id/user/avatar/default.png)
![Avatar border](https://s.kaskus.id/images/avatarborder/1.gif)
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Mari bergabung, dapatkan informasi dan teman baru!
![Website, Webmaster, Webdeveloper](https://s.kaskus.id/r200x200/ficon/image-13.png)
Website, Webmaster, Webdeveloper![KASKUS Official KASKUS Official](https://s.kaskus.id/kaskus-next/next-assets/images/icon-official-badge.svg)
23.3KThread•4.4KAnggota
Urutkan
Terlama
![Guest](https://s.kaskus.id/user/avatar/default.png)
![Avatar border](https://s.kaskus.id/images/avatarborder/1.gif)
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru