arthuryinzhen/laravel-jd-logistic

京东物流的laravel包

dev-master 2019-01-12 10:43 UTC

This package is auto-updated.

Last update: 2022-01-14 13:56:29 UTC


README

Laravel 5 京东物流接口

安装

可以通过Composer安装ActionLog Service Provider,要求包名为arthuryinzhen/laravel-jd-logistic,并在项目中的composer.json文件中将minimum-stability设置为dev(Laravel 5所需)。

{
    "require": {
           "arthuryinzhen/laravel-jd-logistic": "dev-master"
    },
   
}

或者

使用Composer要求此包

composer require arthuryinzhen/laravel-jd-logistic dev-master

使用composer update更新包或使用composer install安装。

用法

要使用ActionLog Service Provider,您必须在启动Laravel应用程序时注册提供者。有两种基本方法可以做到这一点。

config/app.php中找到providers键并注册ActionLog Service Provider。

    'providers' => [
        // ...
        
        'Arthuryinzhen\JDLogistic\JDLogisticServiceProvider',
    ]

对于Laravel 5.1+

    'providers' => [
        // ...
        Arthuryinzhen\JDLogistic\JDLogisticServiceProvider::class,
    ]

config/app.php中找到aliases键。

    'aliases' => [
        // ...
        'JDLogistic' => 'Arthuryinzhen\JDLogistic\Facades\JDLogisticFacade',
    ]

对于Laravel 5.1+

    'aliases' => [
        // ...
        'JDLogistic' => Arthuryinzhen\JDLogistic\Facades\JDLogisticFacade::class,
    ]

配置

要使用自己的设置,发布配置。

$ php artisan vendor:publish

config/JdLogistic.php

	'client' => [
            'appKey'      => env('JD_CLIENT_APP_KEY', '26EAC2509056EB38FB623D9A49296D2C'),
            'appSecret'   => env('JD_CLIENT_APP_SECRET', '1abdc5a97ecb4594ab7b772296bcfbbd'),
            'accessToken' => env('JD_CLIENT_ACCESS_TOKEN', '1f1d3048-220a-484d-ad93-f3808d9aacc1'),
            'serverUrl'   => env('JD_CLIENT_SERVER_URL', 'https://api.jd.com/routerjson'),
        ],

最后一步

修改你的.env

JD_CLIENT_APP_KEY=
JD_CLIENT_APP_SECRET=
JD_CLIENT_ACCESS_TOKEN=
JD_CLIENT_SERVER_URL="https://api.jd.com/routerjson"

示例

public function getTest(Request $request)
{
    $array = $request->input();
    $lotus = new JDLogisticRepository();
    $result = $lotus->ldopWaybillReceiveRequest($array);
    dd($result);
}