gufy/rajaongkir

使用 Guzzle 的 Rajaongkir API 的替代方案

v1.0.0 2016-09-06 10:30 UTC

This package is auto-updated.

Last update: 2024-09-13 18:21:11 UTC


README

rajaongkir PHP API 的另一个替代方案。它使用 GuzzleHttp 作为其底层 CURL 请求

安装

在您的 composer 上运行此命令 composer require gufy/rajaongkir

用法

<?php
use Gufy\Rajaongkir\Rajaongkir;
use Gufy\Rajaongkir\Province;
use Gufy\Rajaongkir\City;
use Gufy\Rajaongkir\Cost;
use Gufy\Rajaongkir\Waybill;
// initialize api. first argument will be your api key, and the second one is your package
Rajaongkir::init('your-api-key', 'starter');

// get all provinces
$provinces = Province::all();

// get cities
$cities = City::all();

// get cities based on province id
$cities = City::all($province_id);

// get cost
$cost = Cost::get(['city'=>$origin_city_id], ['city'=>$destination_city], $weight, 'jne');

// get waybill
$cost = Waybill::find('jne', 'your-waybill');