Skip to content

Releases: hborras/twitter-php-ads-sdk

v3.0.1

24 Jul 08:41
Compare
Choose a tag to compare
v3.0.1

V 3.0.0

22 Jul 09:29
5729e49
Compare
Choose a tag to compare

2.0.2

05 Feb 10:35
Compare
Choose a tag to compare

New version to adopt Ads API v2.

Breaking changes updated!

Soon will come more updates I'll try to be more regular

v2.0.0

04 Jan 21:50
Compare
Choose a tag to compare

New version to adopt Ads API v2.

Breaking changes updated!

Soon will come more updates I'll try to be more regular

v1.0.5

25 Nov 10:05
Compare
Choose a tag to compare

Breaking Changes

This new version includes some breaking changes that make incompatible with the previous library.

I've tried to make it easier to use it, you now only needs to instantiate one time the API class, and you can forget about it. Before you needed to move it across all your classes and made the code more difficult

Future changes

Implement Twitter Ads API v2

Quick Start

const CONSUMER_KEY = 'your consumer key';
const CONSUMER_SECRET = 'your consumer secret';
const ACCESS_TOKEN = 'access token';
const ACCESS_TOKEN_SECRET = 'access token secret';
const ACCOUNT_ID = 'account id';

// Create Twitter Ads Api Instance
$api = TwitterAds::init(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);

$accounts = $api->getAccounts();
// load up the account instance, campaign and line item
$account = new Account(ACCOUNT_ID);
$account->read();
$campaigns = $account->getCampaigns('', [CampaignFields::COUNT => 1]);
$campaigns->setUseImplicitFetch(false);
$campaignsData = [];

// Create your campaign
$campaign = new Campaign();
$campaign->setAccount($account);
$campaign->setFundingInstrumentId($account->getFundingInstruments()->first()->getId());
$campaign->setDailyBudgetAmountLocalMicro(1000000);
$campaign->setName("My first campaign");
$campaign->setPaused(false);
$campaign->setStartTime(new \DateTime());
$campaign->save();

// Automatic fetch from API when collection arrives to end:
$campaign->setUseImplicitFetch(true);

// Default fetch from API when collection arrives to end (GLOBAL):
Cursor::setDefaultUseImplicitFetch(true);

// Disable it
Cursor::setDefaultUseImplicitFetch(false);

// Async stats
$stats = $lineItem->stats(
[
AnalyticsFields::METRIC_GROUPS_BILLING,
AnalyticsFields::METRIC_GROUPS_MOBILE_CONVERSION,
AnalyticsFields::METRIC_GROUPS_ENGAGEMENT,
],
[
AnalyticsFields::START_TIME => $date[0],
AnalyticsFields::END_TIME => $date[1],
AnalyticsFields::GRANULARITY => Enumerations::GRANULARITY_TOTAL,
AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER
], true
);

// Sync stats, set parameter to false, or not include it
$stats = $lineItem->stats(
[
AnalyticsFields::METRIC_GROUPS_BILLING,
AnalyticsFields::METRIC_GROUPS_MOBILE_CONVERSION,
AnalyticsFields::METRIC_GROUPS_ENGAGEMENT,
],
[
AnalyticsFields::START_TIME => $date[0],
AnalyticsFields::END_TIME => $date[1],
AnalyticsFields::GRANULARITY => Enumerations::GRANULARITY_TOTAL,
AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER
], false
);
Field Constants

Now, there are able Fields classes for every included class to make easier filter and create data .. code:: php AnalyticsFields::GRANULARITY -> 'granularity' AnalyticsFields::PLACEMENT -> 'placement' . . .

v1.0.4

23 Nov 17:26
Compare
Choose a tag to compare

Breaking Changes

This new version includes some breaking changes that make incompatible with the previous library.

I've tried to make it easier to use it, you now only needs to instantiate one time the API class, and you can forget about it. Before you needed to move it across all your classes and made the code more difficult

Future changes

Implement Twitter Ads API v2

Quick Start

const CONSUMER_KEY = 'your consumer key';
const CONSUMER_SECRET = 'your consumer secret';
const ACCESS_TOKEN = 'access token';
const ACCESS_TOKEN_SECRET = 'access token secret';
const ACCOUNT_ID = 'account id';

// Create Twitter Ads Api Instance
$api = TwitterAds::init(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);

$accounts = $api->getAccounts();
// load up the account instance, campaign and line item
$account = new Account(ACCOUNT_ID);
$account->read();
$campaigns = $account->getCampaigns('', [CampaignFields::COUNT => 1]);
$campaigns->setUseImplicitFetch(false);
$campaignsData = [];

// Create your campaign
$campaign = new Campaign();
$campaign->setAccount($account);
$campaign->setFundingInstrumentId($account->getFundingInstruments()->first()->getId());
$campaign->setDailyBudgetAmountLocalMicro(1000000);
$campaign->setName("My first campaign");
$campaign->setPaused(false);
$campaign->setStartTime(new \DateTime());
$campaign->save();

// Automatic fetch from API when collection arrives to end:
$campaign->setUseImplicitFetch(true);

// Default fetch from API when collection arrives to end (GLOBAL):
Cursor::setDefaultUseImplicitFetch(true);

// Disable it
Cursor::setDefaultUseImplicitFetch(false);

// Async stats
$stats = $lineItem->stats(
[
AnalyticsFields::METRIC_GROUPS_BILLING,
AnalyticsFields::METRIC_GROUPS_MOBILE_CONVERSION,
AnalyticsFields::METRIC_GROUPS_ENGAGEMENT,
],
[
AnalyticsFields::START_TIME => $date[0],
AnalyticsFields::END_TIME => $date[1],
AnalyticsFields::GRANULARITY => Enumerations::GRANULARITY_TOTAL,
AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER
], true
);

// Sync stats, set parameter to false, or not include it
$stats = $lineItem->stats(
[
AnalyticsFields::METRIC_GROUPS_BILLING,
AnalyticsFields::METRIC_GROUPS_MOBILE_CONVERSION,
AnalyticsFields::METRIC_GROUPS_ENGAGEMENT,
],
[
AnalyticsFields::START_TIME => $date[0],
AnalyticsFields::END_TIME => $date[1],
AnalyticsFields::GRANULARITY => Enumerations::GRANULARITY_TOTAL,
AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER
], false
);
Field Constants

Now, there are able Fields classes for every included class to make easier filter and create data .. code:: php AnalyticsFields::GRANULARITY -> 'granularity' AnalyticsFields::PLACEMENT -> 'placement' . . .

v1.0.3

03 Sep 17:39
Compare
Choose a tag to compare

Breaking Changes

This new version includes some breaking changes that make incompatible with the previous library.

I've tried to make it easier to use it, you now only needs to instantiate one time the API class, and you can forget about it. Before you needed to move it across all your classes and made the code more difficult

Future changes

Implement Twitter Ads API v2

Quick Start

const CONSUMER_KEY = 'your consumer key';
const CONSUMER_SECRET = 'your consumer secret';
const ACCESS_TOKEN = 'access token';
const ACCESS_TOKEN_SECRET = 'access token secret';
const ACCOUNT_ID = 'account id';

// Create Twitter Ads Api Instance
$api = TwitterAds::init(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);

$accounts = $api->getAccounts();
// load up the account instance, campaign and line item
$account = new Account(ACCOUNT_ID);
$account->read();
$campaigns = $account->getCampaigns('', [CampaignFields::COUNT => 1]);
$campaigns->setUseImplicitFetch(false);
$campaignsData = [];

// Create your campaign
$campaign = new Campaign();
$campaign->setAccount($account);
$campaign->setFundingInstrumentId($account->getFundingInstruments()->first()->getId());
$campaign->setDailyBudgetAmountLocalMicro(1000000);
$campaign->setName("My first campaign");
$campaign->setPaused(false);
$campaign->setStartTime(new \DateTime());
$campaign->save();

// Automatic fetch from API when collection arrives to end:
$campaign->setUseImplicitFetch(true);

// Default fetch from API when collection arrives to end (GLOBAL):
Cursor::setDefaultUseImplicitFetch(true);

// Disable it
Cursor::setDefaultUseImplicitFetch(false);

// Async stats
$stats = $lineItem->stats(
[
AnalyticsFields::METRIC_GROUPS_BILLING,
AnalyticsFields::METRIC_GROUPS_MOBILE_CONVERSION,
AnalyticsFields::METRIC_GROUPS_ENGAGEMENT,
],
[
AnalyticsFields::START_TIME => $date[0],
AnalyticsFields::END_TIME => $date[1],
AnalyticsFields::GRANULARITY => Enumerations::GRANULARITY_TOTAL,
AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER
], true
);

// Sync stats, set parameter to false, or not include it
$stats = $lineItem->stats(
[
AnalyticsFields::METRIC_GROUPS_BILLING,
AnalyticsFields::METRIC_GROUPS_MOBILE_CONVERSION,
AnalyticsFields::METRIC_GROUPS_ENGAGEMENT,
],
[
AnalyticsFields::START_TIME => $date[0],
AnalyticsFields::END_TIME => $date[1],
AnalyticsFields::GRANULARITY => Enumerations::GRANULARITY_TOTAL,
AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER
], false
);
Field Constants

Now, there are able Fields classes for every included class to make easier filter and create data .. code:: php AnalyticsFields::GRANULARITY -> 'granularity' AnalyticsFields::PLACEMENT -> 'placement' . . .

v0.2.5

13 Jul 09:39
Compare
Choose a tag to compare
v0.2.

v0.2.4

13 Jul 08:46
Compare
Choose a tag to compare
v0.2.4

v0.2.3

08 May 17:06
Compare
Choose a tag to compare

Analytics for more entities