zierhut-it/spotify-ads-php-client

此包已废弃,不再维护。未建议替代包。

Spotify营销API的非官方PHP客户端

v0.2.1 2023-03-17 20:22 UTC

This package is auto-updated.

Last update: 2023-12-07 00:33:53 UTC


README

这是一个用于Spotify营销API的非官方PHP客户端。

Maintenance

API覆盖范围

  • 广告账户
  • 广告商
  • 活动
  • 资产
  • 报告
  • 目标
  • 广告集
  • 广告
  • 估算

安装

使用包管理器composer进行安装。

composer require zierhut-it/spotify-ads-php-client

入门

认证

use Spotify\Api\Marketing\Client;

require_once __DIR__ . "/vendor/autoload.php";

$spotify = new Client(
    "<your-client-id>",
    "<your-client-secret>",
);

// This has to be opened in a browser to grant access
$url = $spotify->auth->getRedirectUrl();

// Save the result for later reuse
$refreshToken = $spotify->auth->getRefreshToken("<code received from the callback>");

保持登录状态

// You may set the refresh token again next time, so no new login and callback is needed
$spotify->auth->setRefreshToken("<your refresh token>");

运行报告

$report = $spotify->newReport();

// You can set options using a simple string
$report->addAdAccountId("<optional-ad-account-id>");

// Or chain multiple of those
$report
    ->addDimension("CAMPAIGN")
    ->addDimension("AD_SET");

// Or don't use chaining
$report->addField("CLICKS");
$report->addField("IMPRESSIONS");

// Or pass multiple values
$report->addField("CTR", "SPEND");

// Or even arrays
$report->addField(["COMPLETION_RATE", "COMPLETES"]);

// When all parameters are set to your liking, make the actual request
$results = $report->run();

// You can use the returned $results or just iterate the report
foreach($report as $row) {
    print_r($row);
}

贡献

欢迎提交pull请求和问题。对于重大更改,请首先提交一个问题来讨论您想要进行的更改。