阿里巴巴开放平台 sdk -PHP

阿里巴巴开放平台SDK

.

Installing

$ composer require liaosp/ali_open -vvv

Usage

在这里插入图片描述
场景: 拉取阿里巴巴商家的采购数据,同步到erp上,采用的是多用户模式,即不需要获取token,直接到open.1688.com 获取持久access_token ,故没有把获取token 的方式分装到里面,大家可以参考这篇文章:https://liaosp.blog.csdn.net/article/detai...
说明:本例子是因为官方sdk看得太累了,所以自己封装一下签名,供大家参考!

        $obj = new \Liaosp\AliOpen\AliOpen(['page'=>1]);
        $obj->setAppkey('你的appkey');
        $obj->setAppsecret('你的秘钥');
        $obj->setAccessToken('自己想办法去获取token,如果设置的是多用户单用户的直接复制,应用管理中的token');//参考:https://liaosp.blog.csdn.net/article/details/103440299
        $res =$obj->order->setApi('com.alibaba.trade:alibaba.trade.getBuyerOrderList-1')->get(); //api 就是阿里巴巴文档中的
        var_dump($res);

项目中可以继承他:

<?php

namespace App\Services\AliOpen;

class AliOpen extends \Liaosp\AliOpen\AliOpen
{
    public function __construct($params = array())
    {
        $this->setAppkey('39376**');
        $this->setAppsecret('0RsvFZYV**');
        $this->access_token = '06410386-242c-41f6-8a20-5e7e0d2b6229';
        parent::__construct($params);
    }
}

获取订单列表的例子

        $get_data =( new AliOpen([     //这边的AliOpen ,是你设置appkey的对象
            'page'=>1,
            'pageSize'=>100,
        ]))
            ->order
            ->setApi('com.alibaba.trade:alibaba.trade.getBuyerOrderList-1')
            ->get();

获取订单详情的例子

        $get_data = (new AliOpen([
            'webSite'=>1688,
            'orderId'=>$this->app->order_id,
        ]))
            ->order
            ->setApi('com.alibaba.trade:alibaba.trade.get.buyerView-1')
            ->get();

你的星星是我持续更新的动力
https://github.com/liaoshengping/ali_open

和我做朋友?

https://www.cnblogs.com/liaosp/p/11075260....

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
未填写
文章
38
粉丝
16
喜欢
144
收藏
135
排名:319
访问:3.0 万
私信
所有博文
社区赞助商