PHP code example of zhuxiaojin / zx-yz-sdk

1. Go to this page and download the library: Download zhuxiaojin/zx-yz-sdk 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/ */

    

zhuxiaojin / zx-yz-sdk example snippets




$clientId = "YOUR_CLIENT_ID";
$clientSecret = "YOUR_CLIENT_SECRET";
$resp = (new \Youzan\Open\Token($clientId, $clientSecret))->refreshToken('YOUR_REFRESH_TOKEN');
var_dump($resp);
 php
 php
lientId = "YOUR_CLIENT_ID";
$clientSecret = "YOUR_CLIENT_SECRET";
$resp = (new \Youzan\Open\Token($clientId, $clientSecret))->getToolAppToken('YOUR_CODE');
var_dump($resp);
 php
lientId = "YOUR_CLIENT_ID";
$clientSecret = "YOUR_CLIENT_SECRET";

// 1. 不获取refresh_token
$resp = (new \Youzan\Open\Token($clientId, $clientSecret))->getSelfAppToken('YOUR_KDT_ID');
var_dump($resp);

// 2. 获取refresh_token
$config['refresh'] = true;  //是否获取refresh_token(可通过refresh_token刷新token)
$resp = (new \Youzan\Open\Token($clientId, $clientSecret))->getSelfAppToken('YOUR_KDT_ID', $config);
var_dump($resp);
 php
ccessToken = 'YOUR_TOKEN';
$client = new \Youzan\Open\Client($accessToken);

$method = 'youzan.item.get';
$apiVersion = '3.0.0';

$params = [
    'alias' => 'fa8989ad342k',
];

$response = $client->post($method, $apiVersion, $params);
var_dump($response);
 php
lient = new \Youzan\Open\Client();

$method = 'youzan.item.get';
$apiVersion = '3.0.0';

$params = [
    'alias' => 'fa8989ad342k',
];

$response = $client->post($method, $apiVersion, $params);
var_dump($response);