PHP code example of onetech / easy-lazada

1. Go to this page and download the library: Download onetech/easy-lazada 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/ */

    

onetech / easy-lazada example snippets


use Onetech\EasyLazada\Lazada;

gion' => 'TH',
    'app_key' => '',
    'app_secret' => '',
    'redirect_uri' => 'https://admin.erp.local',
    'debug' => true,
    'sandbox' => true,
    'log' => [
        'name' => 'foundation',
        'file' => sys_get_temp_dir() . '/foundation.log',
        'level' => 'debug',
        'permission' => 0777,
    ],
    'cache' => new Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir())
]);

//1. 创建授权地址,引导用户进行授权
echo $lazada->oauth->authorizer->create();

//2. 从redirect url中获取code值,去换取access_token等信息
$code = $_GET['code'];
echo $lazada->access_token->setCode($code)->getToken();//创建token

//$lazada->access_token->refresh();
//$lazada->access_token->getToken();
//$lazada->access_token->getRefreshToken();
//$lazada->access_token->delToken();


$order_id = 13800138000;
$res = $lazada->order->getOrder($order_id);