Download the PHP package goletter/hyperf-adv without Composer

On this page you can find all versions of the php package goletter/hyperf-adv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hyperf-adv

ADV SDK

多平台广告 API SDK,目前支持 Facebook Marketing API、TikTok Business API、Google Ads API。

安装

Hyperf 项目可发布配置:

快速开始(推荐)

Hyperf DI(读取 config/autoload/adv.php

发布配置后,可注入工厂;create() 会自动合并对应平台配置(如 api_versiondeveloper_token):

注册自定义平台

PlatformBundle 的 client / account / business / campaign / report 须为已支持平台类型(Facebook / TikTok / Google 对应类),以便 IDE 跳转与类型检查。Facebook Bundle 另含 catalogpixel(其它平台为 null)。自定义平台通常基于现有实现扩展或包装:

多 Token 轮询(失败切换)

传入 token 数组后,单次请求从当前 token 开始;若抛出 API / Token 失效异常,自动换下一个,直到全部失败才抛出最后一次异常。成功后会粘滞在可用 token。

Facebook 在切换 token 前会打 token-failover 日志(若配置了 call log handler)。限流会先在当前 token 上按 max_retries 退避,仍失败再切下一个 token。

跨平台捕获 Token 失效:

使用示例

Google Ads

需要 OAuth2 Access TokenDeveloper Token,操作 MCC 下子账户时还需 Login Customer ID(经理账户 ID,纯数字)。

应用授权 OAuth (GoogleAuth)

Google Ads OAuth2 分两步(默认 scope:https://www.googleapis.com/auth/adwords):

  1. 授权页:生成 URL,引导用户同意并返回 code
  2. 回调:用 code 换 Access Token / Refresh Token(access_type=offline + prompt=consent 才会返回 refresh_token)

拿到 access_token 后即可调用 Ads API:

业务侧也可通过 AdvFactory::make(3, $oauthToken)AdvFactory::make('google', $oauthToken) 获取平台 Bundle(含 client / account / business / campaign / report)。

环境变量(可选):

基础 Client

应用授权 OAuth (FacebookAuth / dialog/oauth)

Facebook 应用授权分两步:

  1. dialog/oauth:生成授权页 URL,引导用户跳转 Facebook 登录并授权
  2. 回调:用返回的 code 换 Access Token(默认再换长期 Token,约 60 天)

也可通过 FacebookBusiness(内部委托 FacebookAuth):

配置项(config/autoload/adv.php,发布后可选填写):

Business Manager 管理 (FacebookBusiness)

账户管理 (FacebookAccount)

广告系列管理 (FacebookCampaign)

商品目录管理 (FacebookCatalog)

需要 catalog_management(及通常的 business_management)权限。也可通过 AdvFactory::facebook($token)->catalog 使用。

像素管理 (FacebookPixel)

也可通过 AdvFactory::facebook($token)->pixel 使用。FacebookBusiness 上原有像素方法仍可用,但已标记 @deprecated,建议迁移到本类。

报告查询 (FacebookReport)

在项目中的实际使用示例

获取 Business Manager 列表

获取 BM 下的广告账户

获取账户消耗数据

更新账户名称和限额

管理账户分配用户

管理广告系列

异常处理

API 版本

默认使用 Facebook API v24.0,可在创建 Client 时自定义:

在账户类中快捷访问广告系列

TikTok 使用示例

应用授权 OAuth (TikTokAuth / portal/auth)

TikTok Marketing API 应用授权分两步:

  1. portal/auth:生成授权页 URL,引导用户授权广告账户
  2. 回调:用返回的 auth_code 换 Access Token / Refresh Token

配置项(config/autoload/adv.php,发布后可选填写):

基础 Client

报表查询 (TikTokReport)

广告主信息 (TikTokAccount)

在项目中的实际使用示例(同步 TikTok 消耗到数据库)

TikTok 异常处理

特性


All versions of hyperf-adv with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
guzzlehttp/guzzle Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package goletter/hyperf-adv contains the following files

Loading the files please wait ...