PHP code example of wahyuandi840 / myrajaongkir

1. Go to this page and download the library: Download wahyuandi840/myrajaongkir library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wahyuandi840 / myrajaongkir example snippets


protected $apiKey = 'isi_api_key_anda_disini';



$data = MyRajaOngkir\MyRajaOngkir::Provinsi()->all();

$data = MyRajaOngkir\MyRajaOngkir::Provinsi()->find($id);

$data = MyRajaOngkir\MyRajaOngkir::Provinsi()->search('province', $name = "ja")->get();

$data = MyRajaOngkir\MyRajaOngkir::Kota()->all();

$data = MyRajaOngkir\MyRajaOngkir::Kota()->find($id);

$data = MyRajaOngkir\MyRajaOngkir::Kota()->search('city_name', $name = "banyu")->get();

$data = MyRajaOngkir\MyRajaOngkir::Kota()->byProvinsi($provinsi_id)->get();

$data = MyRajaOngkir\MyRajaOngkir::Kota()->byProvinsi($provinsi_id)->search('city_name', $name)->get();

$data = MyRajaOngkir\MyRajaOngkir::Kecamatan()->all();

$data = MyRajaOngkir\MyRajaOngkir::Kecamatan()->search('subdistrict_name', $name = "kranggan")->get();;

$data = MyRajaOngkir\MyRajaOngkir::Kecamatan()->byCity($city_id)->get();

$data = MyRajaOngkir\MyRajaOngkir::Cost([
	'origin' 		=> 501, // id kota asal
	'destination' 	=> 114, // id kota tujuan
	'weight' 		=> 1700, // berat satuan gram
	'courier' 		=> 'jne', // kode kurir pengantar ( jne / tiki / pos )
])->get();

$data = MyRajaOngkir\MyRajaOngkir::Cost([
    	'origin' 	        => $origin, // id kota asal
        'originType'            => 'city',
        'destination'           => $destination, // id kota tujuan
        'destinationType'       => 'subdistrict',
    	'weight' 		=> $weight, // berat satuan gram
    	'courier' 		=> $courier, // kode kurir pengantar ( jne / tiki / pos )
    ])->get();