100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 阿里巴巴开放平台composer sdk demo | php-sdk

阿里巴巴开放平台composer sdk demo | php-sdk

时间:2021-06-12 10:15:43

相关推荐

阿里巴巴开放平台composer sdk demo | php-sdk

阿里巴巴开放平台SDK

Special thanks to the generous sponsorship by:

.

Installing

$ composer require liaosp/ali_open -vvv

Usage

场景: 拉取阿里巴巴商家的采购数据,同步到erp上,采用的是多用户模式,即不需要获取token,直接到 获取持久access_token ,故没有把获取token 的方式分装到里面,大家可以参考这篇文章:https://liaosp./article/details/103440299

说明:本例子是因为官方sdk看得太累了,所以自己封装一下签名,供大家参考!

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

项目中可以继承他:

<?phpnamespace 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'=>'订单id',]))->order->setApi('com.alibaba.trade:alibaba.trade.get.buyerView-1')->get();

和我做朋友?

Contributing

You can contribute in one of three ways:

File bug reports using the issue tracker.Answer questions or fix bugs on the issue tracker.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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。