PHP code example of yekern / alibaba_open

1. Go to this page and download the library: Download yekern/alibaba_open library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yekern / alibaba_open example snippets


        $obj = new \Yekern\AlibabaOpen\AlibabaClient(['page'=>1]);
        $obj->setAppkey('你的appkey');
        $obj->setAppsecret('你的秘钥');
        $obj->setAccessToken('自己想办法去获取token,如果设置的是多用户单用户的直接复制,应用管理中的token');//如果是单用户模式,无需添加此参数
        $res =$obj->order->setApi('com.alibaba.trade:alibaba.trade.getBuyerOrderList-1')->get(); //api 就是阿里巴巴文档中的
        var_dump($res);




namespace App\Services\AliOpen;


class AliOpen extends \Yekern\AlibabaOpen\AlibabaClient
{
    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  \Yekern\AlibabaOpen\AlibabaClient([     //这边的AliOpen ,是你设置appkey的对象
            'page'=>1,
            'pageSize'=>100,
        ]))
            ->order
            ->setApi('com.alibaba.trade:alibaba.trade.getBuyerOrderList-1')
            ->get();

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


        $get_data = (new  \Yekern\AlibabaOpen\AlibabaClient())
            ->product
            ->productFollow(new \Yekern\AlibabaOpen\entity\ProductFollowParams('532137286888'))//建议使用此种方法传参
            ->get();

$get_data = (new \Yekern\AlibabaOpen\AlibabaClient())
    ->setAppkey('you appkey')
    ->setAppsecret('you Appsecret')
    ->setAccessToken('you TOKEN')
    ->product
    ->getCrossProductInfo(new \Yekern\AlibabaOpen\entity\CrossProductInfoParam('615890334160')) //商品ID
    ->post();