PHP code example of zierhut-it / spotify-ads-php-client
1. Go to this page and download the library: Download zierhut-it/spotify-ads-php-client 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/ */
zierhut-it / spotify-ads-php-client example snippets
use Spotify\Api\Marketing\Client;
-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);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.