PHPackages                             yuanchao/pdd-union-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. yuanchao/pdd-union-php-sdk

ActiveLibrary

yuanchao/pdd-union-php-sdk
==========================

pdd-union-php-sdk

v1.0(6y ago)041MITPHPPHP ^5.5|^7.0

Since Feb 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/yccphp/pdd-union-php-sdk)[ Packagist](https://packagist.org/packages/yuanchao/pdd-union-php-sdk)[ RSS](/packages/yuanchao-pdd-union-php-sdk/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

拼多多开放平台PHP版本的SDK
----------------

[](#拼多多开放平台php版本的sdk)

- 环境要求：php 5.5版本及以上，使用composer包管理工具
- 执行一下 composer install 安装命令
- 该SDK使用 composer 对src下面的代码进行命名空间自动导入，namespace 自动导入的规则是[psr4 规范](https://www.php-fig.org/psr/psr-4/)
- 该SDK共有2个文件夹，src文件夹下面是sdk主功能文件夹。example文件夹下面是所有接口的demo，作为测试样例参考。

src文件夹下面文件功能说明
--------------

[](#src文件夹下面文件功能说明)

- PopAccessTokenClient 类
    - generate : 根据从授权后回调地址那里拿到的code 值，然后去服务器获取access\_token和refresh\_token以及过期时间等值
    - refresh：由于access\_token时效性是24小时，refresh\_token的时效性是30天，所以，当acces\_token过期后，利用refresh\_token进行重新获取access\_token
- PopHttpClient 类
    - syncInvoke : 把接口名称 type 以及各自接口对应的业务参数，access\_token(如果需要授权)传给这个接口即可获取到对应接口的返回值。
- Api/Request
    - 这个文件夹下面存放所有接口的自定义请求Request类
- Common
    - 这个文件夹下面存放所有的公共功能类
- Token
    - 这个文件夹下面存放获取和刷新token相关接口的request

example 文件夹说明
-------------

[](#example-文件夹说明)

- AccessToken.php 获取 access\_token 的示例代码
- Config\_sample.php 使用的时候文件重命名为Config.php，替换文件里面的配置信息
- PddXXXX.php 针对某个特定的接口对应的示例代码

使用示例
----

[](#使用示例)

### 用户授权

[](#用户授权)

```
$clientId = "your app clientId";
$clientSecret = "your app clientSecret";
$refreshToken = "your app refreshToken";
$code = "your code";

$accessTokenClient = new PopAccessTokenClient($clientId,$clientSecret);

// 生成AccessToken

$result = $accessTokenClient->generate($code);
$result = json_encode($result->getContent(),JSON_UNESCAPED_UNICODE);
echo $result;

// 刷新AccessToken

$result = $accessTokenClient->refresh($refreshToken);
$result = json_encode($result->getContent(),JSON_UNESCAPED_UNICODE);
echo $result;
```

### 访问接口（以获取商品详情接口为例）：

[](#访问接口以获取商品详情接口为例)

```
$clientId = "your app clientId";
$clientSecret = "your app clientSecret";
$pid = "your pid";

//创建client客户端
$client = new PopHttpClient($clientId, $clientSecret);

//创建请求对象
$request = new PddDdkGoodsDetailRequest();
$request->setGoodsIdList(array(6730722720));
$request->setPid($pid);
$request->setCustomParameters('str');
$request->setZsDuoId(1111111);
$request->setPlanType(1);

//发起接口请求
try{
	$response = $client->syncInvoke($request);
} catch(Com\Pdd\Pop\Sdk\PopHttpException $e){
	echo $e->getMessage();
	exit;
}

$content = $response->getContent();

//判断是否异常
if(isset($content['error_response'])){
	echo "异常返回";
}
echo json_encode($content,JSON_UNESCAPED_UNICODE);
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2287d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/280e78a6790d59cce70a5c458d327e3a94f10dd6a2c8ca3e1cee9c445a3e389f?d=identicon)[yuanchao](/maintainers/yuanchao)

### Embed Badge

![Health badge](/badges/yuanchao-pdd-union-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/yuanchao-pdd-union-php-sdk/health.svg)](https://phpackages.com/packages/yuanchao-pdd-union-php-sdk)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
