PHPackages                             cloudycity/tencent-marketing-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. [API Development](/categories/api)
4. /
5. cloudycity/tencent-marketing-sdk

ActiveLibrary[API Development](/categories/api)

cloudycity/tencent-marketing-sdk
================================

Tencent MarketingAPI SDK

v1.0.0(5y ago)1443MITPHPPHP &gt;=5.6.0

Since Apr 6Pushed 5y agoCompare

[ Source](https://github.com/CloudyCity/tencent-marketing-sdk)[ Packagist](https://packagist.org/packages/cloudycity/tencent-marketing-sdk)[ RSS](/packages/cloudycity-tencent-marketing-sdk/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (2)Used By (0)

广点通SDK
======

[](#广点通sdk)

[![Latest Version on Packagist](https://camo.githubusercontent.com/06c7c8240bc833680e20d29f6d26c56422bdd0a644364a0a5f6ba33ed53a1083/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c6f756479636974792f74656e63656e742d6d61726b6574696e672d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cloudycity/tencent-marketing-sdk)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/0ea0a4322953f7df9a60b3cfc972b60bdc66bc1620f163fe1cf2cc2263e885dd/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636c6f756479636974792f74656e63656e742d6d61726b6574696e672d73646b2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/cloudycity/tencent-marketing-sdk)[![StyleCI](https://camo.githubusercontent.com/2c355afadf65669e18a3fb57ead1ae08eb2abf284f6e8ad205a8ac254674dc26/68747470733a2f2f7374796c6563692e696f2f7265706f732f3234343538303734312f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/244580741)[![Quality Score](https://camo.githubusercontent.com/51e57587ab934da396b49be5c278246a37f2b7c1f4eff7acd23c4abb4bb1c34f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f636c6f756479636974792f74656e63656e742d6d61726b6574696e672d73646b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/cloudycity/tencent-marketing-sdk)[![Total Downloads](https://camo.githubusercontent.com/322c9a412fadf1424733e2fe8ba6cf8684477ce72656d408316ddd55ed15bb4a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c6f756479636974792f74656e63656e742d6d61726b6574696e672d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/cloudycity/tencent-marketing-sdk)[![standard-readme compliant](https://camo.githubusercontent.com/4d148b38f9c13f71b15b80f0bd583698fd5a5ab9bd7dfe61d40e1e30aec35399/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f726561646d652532307374796c652d7374616e646172642d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/RichardLitt/standard-readme)

简体中文 | [English](./README.en.md)

内容列表
----

[](#内容列表)

- [简介](#%E7%AE%80%E4%BB%8B)
- [安装](#%E5%AE%89%E8%A3%85)
- [使用说明](#%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E)
    - [授权](#%E6%8E%88%E6%9D%83)
    - [基础调用](#%E5%9F%BA%E7%A1%80%E8%B0%83%E7%94%A8)
    - [请求参数与响应类型](#%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0%E4%B8%8E%E5%93%8D%E5%BA%94%E7%B1%BB%E5%9E%8B)
    - [自动翻页](#%E8%87%AA%E5%8A%A8%E7%BF%BB%E9%A1%B5)
    - [工厂](#%E5%B7%A5%E5%8E%82)
- [维护者](#%E7%BB%B4%E6%8A%A4%E8%80%85)
- [如何贡献](#%E5%A6%82%E4%BD%95%E8%B4%A1%E7%8C%AE)
- [使用许可](#%E4%BD%BF%E7%94%A8%E8%AE%B8%E5%8F%AF)

简介
--

[](#简介)

> 当前支持的API版本: v1.1

本仓库从 `MrSuperLi/tencent-marketing-api-php-sdk` 分支

相较于原仓库上的改动:

1. 集成授权
2. 客户端传入`advertiser_id`参数
3. 客户端按业务(资源)模块调用
4. 请求参数支持数组
5. 支持多种响应类型
6. 使用PSR-2

安装
--

[](#安装)

`composer install cloudycity/tencent-marketing-sdk`

使用说明
----

[](#使用说明)

- `Auth`: 获取、刷新令牌
- `Client`: 调用各资源的主客户端
- `BaseClient`: 发起动作的资源
- `Factory`: 用于获取自定义资源实例的工厂

### 授权

[](#授权)

```
use CloudyCity\TencentMarketingSDK\Auth;
use CloudyCity\TencentMarketingSDK\Kernel\Exceptions\Exception;

$clientId = '';
$clientSecret = '';
$authCode = '';
$redirectUri = '';

$auth = new Auth($clientId, $clientSecret);

try {
    $res = $auth->getTokens($authCode, $redirectUri);
    $refreshToken = $res['data']['refresh_token'];

    $res = $auth->refreshTokens($refreshToken);
} catch (Exception $e) {
    //
}
```

### 基础调用

[](#基础调用)

广点通接口格式统一为: `资源/动作`

**接口示例:**

- `funds/get` 获取资金账户信息
- `advertiser/update` 更新广告主信息

资源对应`Client`对象中的属性，动作对应属性中的方法

**调用示例:**

```
$res = $client->funds->get();
$res = $client->advertiser->update($params);
```

### 请求参数与响应类型

[](#请求参数与响应类型)

```
use CloudyCity\TencentMarketingSDK\Client;
use CloudyCity\TencentMarketingSDK\Kernel\Http\Parameters\Params;
use CloudyCity\TencentMarketingSDK\Kernel\Exceptions\Exception;

$advertiserId = '';
$accessToken = '';

// 可以传入第三个参数来指定响应类型
// 支持的响应类型: array (default) / object / collection / raw (json string)
$client = new Client($advertiserId, $accessToken);

// 使用`Params`类来构建参数
$params = Params::make()->setDateRange('2020-01-01', '2020-01-07')
    ->set('level', 'REPORT_LEVEL_ADGROUP')
    ->groupBy('adgroup_id', 'date')
    ->orderBy('cost', 'desc');

$filter = $params->getFilter()
    ->eq('adgroup_id', 'xxx');

$params->setFilter($filter);

// 或使用数组构建参数
$params = [
    'date_range' => [
        'start_date' => '2020-01-01',
        'end_date' => '2020-01-07',
    ],
    'level' => 'REPORT_LEVEL_ADGROUP',
    'group_by' => [
        'adgroup_id',
        'date'
    ],
    'order_by' => [
        'sort_field' => 'cost',
        'sort_type' => 'DESCENDING'
    ],
    'filtering' => [
        [
            'adgroup_id',
            'EQUALS',
            'xxx'
        ]
    ]
];

try {
    $res = $client->daily_reports->get($params);
} catch (Exception $e) {
    //
}
```

### 自动翻页

[](#自动翻页)

`BaseClient::getAllPages()`通过[Generator](https://www.php.net/manual/zh/language.generators.overview.php)实现翻页逻辑.

```
use CloudyCity\TencentMarketingSDK\Client;
use CloudyCity\TencentMarketingSDK\Kernel\Exceptions\Exception;

$advertiserId = '';
$accessToken = '';
$client = new Client($advertiserId, $accessToken);

try {
    foreach ($client->campaigns->getAllPages() as $page) {
        foreach ($page as $record) {
            var_dump($record);
        }
    }
} catch (Exception $e) {
    //
}
```

### 工厂

[](#工厂)

如果API更新出现了新的资源名称，但是SDK版本未更新，`Client`对象将找不到对应的成员属性。 此时你可以通过工厂类获取一个`BaseClient`实例，建议同时提交新Issue让我给`Client`添加新的成员属性。

```
use CloudyCity\TencentMarketingSDK\Factory;

$advertiserId = '';
$accessToken = '';

$resourceClient = Factory::getClient('new_resource', $advertiserId, $accessToken);
```

维护者
---

[](#维护者)

- @CloudyCity

如何贡献
----

[](#如何贡献)

非常欢迎你的加入！[提一个 Issue](https://github.com/CloudyCity/tencent-marketing-sdk/issues/new) 或者提交一个 Pull Request。

标准 Readme 遵循 [Contributor Covenant](http://contributor-covenant.org/version/1/3/0/) 行为规范。

使用许可
----

[](#使用许可)

[MIT](LICENSE) © CloudyCity

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.4% of commits — single point of failure

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

1862d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a30bac408d56202227d7d978a5befaf1ec37f9c971beaed3145854226f150d24?d=identicon)[CloudyCity](/maintainers/CloudyCity)

---

Top Contributors

[![CloudyCity](https://avatars.githubusercontent.com/u/17662451?v=4)](https://github.com/CloudyCity "CloudyCity (27 commits)")[![lizc9](https://avatars.githubusercontent.com/u/17842810?v=4)](https://github.com/lizc9 "lizc9 (7 commits)")

---

Tags

marketingsdktencentsdkmarketingtencent

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/cloudycity-tencent-marketing-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/cloudycity-tencent-marketing-sdk/health.svg)](https://phpackages.com/packages/cloudycity-tencent-marketing-sdk)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[temporal/sdk

Temporal SDK

4002.2M18](/packages/temporal-sdk)[thenbsp/wechat

微信公众平台第三方 SDK 开发包，优雅、健壮，可扩展，遵循 PSR 开发规范。

9408.2k](/packages/thenbsp-wechat)[yoti/yoti-php-sdk

Yoti SDK for quickly integrating your PHP backend with Yoti

27539.9k1](/packages/yoti-yoti-php-sdk)

PHPackages © 2026

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