PHP code example of asialong / pinduoduo-sdk

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

    

asialong / pinduoduo-sdk example snippets



use \Asialong\PinduoduoSdk\Pdd;

 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'client_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'debug'              => true,
    'member_type'        => 'MERCHANT',//用户角色 :MERCHANT(商家授权),H5(移动端),多多客(JINBAO),
    'redirect_uri'       => 'https://test.xxx.com/callback',
    'log'                => [
        'name'       => 'pdd',
        'file'       => __DIR__ . '/pdd.log',
        'level'      => 'debug',
        'permission' => 0777,
    ],
];
$pdd = new Pdd($config);


$result   = $pdd->api->request('pdd.ddk.goods.detail', ['goods_id_list' => ['395581006']]);


$url = $pdd->pre_auth->authorizationUrl();

$pdd->pre_auth->authorizationRedirect();

$token = $pdd->pre_auth->getAccessToken();
//也可以通过上面得到的 refresh_token 去刷新令牌
//拼多多官方刷新令牌功能暂时无效,token失效就重新授权
//$token = $pdd->pre_auth->refreshToken($token['refresh_token']);

$pinduoduo = $pdd->oauth->createAuthorization($token['token']);

$result   = $pdd->auth_api->request('pdd.ddk.oauth.goods.pid.query');