1. Go to this page and download the library: Download risan/jne 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/ */
risan / jne example snippets
// Include autoloder file.
e.
$jne = new Jne\Jne();
// Search for origin city and get the first mathced item.
$bandung = $jne->searchOrigin('Bandung')->first();
// Search for destination city ang get the first matched item.
$depok = $jne->searchDestination('Depok')->first();
// Create a package instance.
// From bandung to depok 10 Kilograms package.
$myPackage = new Jne\Package($origin, $destination, Jne\Weight::fromKilograms(10));
// Get delivery options for $myPackage.
// @return Jne\Collections\DeliveryOptionCollection
$deliveryOptions = $jne->deliveryOptions($myPackage);
$jne->searchOrigin(string $query);
$jne = new Jne\Jne();
$origins = $jne->searchOrigin('bandar');
// Create an instance of Jne\Jne class.
$jne = new Jne\Jne();
// Find origin locations that match `Bandung`.
$origins = $jne->searchOrigin('Bandung');
// Get the first matched location.
$bandung = $origin->first();
Jne\Location Object
(
[name:protected] => BANDUNG
[code:protected] => QkRPMTAwMDA=
)
$origin = new Jne\Location(string $name, string $code);
$bandung = new Jne\Location('BANDUNG', 'QkRPMTAwMDA=');
// Create an instance of Jne\Jne class.
$jne = new Jne\Jne();
// Find destination locations that match `Depok`.
$destinations = $jne->searchOrigin('Depok');
// Get the first matched location.
$depok = $destinations->first();
$destination = new Jne\Location(string $name, string $code);
$depok = new Jne\Location('DEPOK', 'RFBLMTAwMDA=');
// Create from grams unit.
Jne\Weight::fromGrams(float $grams);
// Create from kilograms unit.
Jne\Weight::fromKilograms(float $kilograms);
// Create from pounds unit.
Jne\Weight::fromPounds(float $pounds);
$weight = Jne\Weight::fromKilograms(10);
$package = new Jne\Package($origin, $destination, $weight);
$jne = new Jne\Jne();
// Create a origin location.
$bandung = new Jne\Location('BANDUNG', 'QkRPMTAwMDA=');
// Find a destination location.
$depok = $jne->searchDestination('DEPOK')->first();
// Create weight.
$weight = Jne\Weight::fromKilograms(10);
$package = new Jne\Package($bandung, $depok, $weight);
$jne = new Jne\Jne();
$jne->deliveryOptions(Jne\Package $package);
$jne = new Jne\Jne();
// Create a origin location.
$bandung = new Jne\Location('BANDUNG', 'QkRPMTAwMDA=');
// Create a destination location.
$depok = new Jne\Location('DEPOK', 'RFBLMTAwMDA=');
// Create weight.
$weight = Jne\Weight::fromKilograms(10);
// Create package.
$package = new Jne\Package($bandung, $depok, $weight);
$deliveryOptions = $jne->deliveryOptions($package);