同步Lazada店铺商品

PHP文件头:
import('lazada.LazopSdk', EXTEND_PATH);
use LazopClient;
use LazopRequest;
use function GuzzleHttp\json_decode;
use function GuzzleHttp\json_encode;
header("Content-Type:text/html; charset=utf8");

Lazada开发者平台地址:https://open.lazada.com/doc/api.htm?spm=a2o9m.11193494.0.0.78eb266blhSWzQ#/api?cid=5&path=/product/create

获得店铺的商品:

switch ($country) {
    case 'Thailand':
        $url = 'https://api.lazada.co.th/rest';
        break;
    case 'Malaysia':
        $url = 'https://api.lazada.com.my/rest';
        break;
    case 'Vietnam':
        $url = 'https://api.lazada.vn/rest';
        break;
    case 'Indonesia':
        $url = 'https://api.lazada.co.id/rest';
        break;
    case 'Philippines':
        $url = 'https://api.lazada.com.ph/rest';
        break;
    case 'Singapore':
        $url = 'https://api.lazada.sg/rest';
        break;
    default:
        $url = '';
        break;
}
# 获取商品——lazada平台
$c = new LazopClient($url, $appkey, $appSecret);
$request = new LazopRequest('/products/get', 'GET');
$request->addApiParam('filter', 'live');//见文档
$request->addApiParam('offset', 0);//见文档
$request->addApiParam('limit', 1);//见文档
$result = json_decode($c->execute($request, $accessToken), true);
$total_products = $result['data']['total_products'];//产品总数
$products_list = $result['data']['products'];//产品列表

  

  

posted @ 2021-05-04 14:40  爱家家的卡卡  阅读(142)  评论(0编辑  收藏  举报