1 Star 0 Fork 1

峰扬/dada-openapi

forked from 过江鱼/dada-openapi 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
峰扬-admin_fyang 峰扬 init 5ba4ac4 1年前
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PHP SDK 接入指南

接入指南

  1. PHP version >= 5.4 & curl extension support
  2. 通过composer安装SDK
  3. 可台在Config配置类,中配置key和Secret。也可以初始化时重新设置
  4. 使用sdk提供的接口进行开发调试
  5. 一些新的功能待开发中

安装

php 安装方法
composer require fyang/dada-openapi

基本用法

php thinkphp 使用方法
    /**
     * @author yangchangdong
     * Date 2019/10/10
     */
    namespace app\index\controller;
    
    use DadaOpenApi\Api\OrderAddApi;
    use DadaOpenApi\Config\Config;
    use DadaOpenApi\Model\OrderModel;
    use DadaOpenApi\Protocol\DadaRequestClient;
    
    class Dada
    {
    
        public function index()
        {
            $config = new Config(0,false);
            $config->setAppKey('*****');
            $config->setAppSecret('****');
    
            $orderModel = new OrderModel();
            $orderModel->setShopNo('11047059');	            // 第三方门店编号
            $orderModel->setOriginId('123456789123');		// 第三方订单号
            $orderModel->setCityCode('CN11');				// 城市code(可以参照城市code接口)
            $orderModel->setCargoPrice(10);
            $orderModel->setIsPrepay(0);
            $orderModel->setReceiverName('张三');
            $orderModel->setReceiverAddress('北京市大兴区');
            $orderModel->setReceiverLat(39.917581);
            $orderModel->setReceiverLng(116.529304);
            $orderModel->setReceiverPhone('13800138000');
            $orderModel->setCallback('local.dada.com/index.php/index/dada/callback');
            $addOrderApi = new OrderAddApi(json_encode($orderModel));
    
            $dada_client = new DadaRequestClient($config, $addOrderApi);
            $resp = $dada_client->makeRequest();
            dump($resp);
            echo json_encode($resp);
        }
    
        public function callback()
        {
            return json(['message'=>'ok']);
        }
    }

测试信息

object(DadaOpenApi\Protocol\DadaResponse)#38 (4) {
  ["status"] => string(4) "fail"
  ["code"] => int(2105)
  ["msg"] => string(50) "订单已下发,如要重发,请使用重发接口"
  ["result"] => NULL
}
{"status":"fail","code":2105,"msg":"\u8ba2\u5355\u5df2\u4e0b\u53d1,\u5982\u8981\u91cd\u53d1,\u8bf7\u4f7f\u7528\u91cd\u53d1\u63a5\u53e3","result":null}

感谢

由达达提供的初始代码,在其上进行了一些二次开发,使用能够直接在thinkphp laravel 中直接使用。
并且能够通过setAppKey设置不同的AppKey和AppSecret
folk自: [yangchangdong/dada-openapi-php-sdk](https://github.com/yangchangdong/dada-openapi-php-sdk)

变更记录

1、使用命名空间
2、v1.0.0

MIT License Copyright (c) 2018 如水网 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

达达配送API接口 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/admin_fyang/dada-openapi.git
git@gitee.com:admin_fyang/dada-openapi.git
admin_fyang
dada-openapi
dada-openapi
master

搜索帮助