totox777 / ongkir
Laravel 4 Ongkir.info API
dev-master
2013-07-23 06:44 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.0.x
This package is not auto-updated.
Last update: 2024-09-24 03:38:52 UTC
README
基于 ongkir.info 包装器的 Laravel 4 ongkir jne
将以下行添加到您的 composer.json 文件中
"totox777/ongkir": "dev-master"
然后,运行
composer update
以拉取最新版本。
将以下行添加到您的 app.php 提供者数组中
'Totox777\Ongkir\OngkirServiceProvider',
并将以下行添加到 app.php 别名数组中
'Ongkir' => 'Totox777\Ongkir\Facades\Profiler',
配置:别忘了在 src/config/config.php 中更改从 ongkir.info 获得的 API 密钥
示例用法
$result = Ongkir::getCost('denpasar','pontianak',1);
if($result!=null){
$prices = $result['price'];
$city = $result['city'];
echo 'Ongkos kirim dari ' . $city->origin . ' ke ' . $city->destination . '<br /><br />';
foreach ($prices->item as $item)
{
echo 'Layanan: ' . $item->service . ', dengan harga : Rp. ' . $item->value . ',- <br />';
}
}
else{
echo 'Tidak ditemukan jalur pengiriman dari asal ke tujuan';
}