PHPackages                             hborras/twitter-php-ads-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. [HTTP &amp; Networking](/categories/http)
4. /
5. hborras/twitter-php-ads-sdk

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

hborras/twitter-php-ads-sdk
===========================

A Twitter supported and maintained Ads API SDK for PHP

V11.0.0(3y ago)56149.8k—9%41[17 issues](https://github.com/hborras/twitter-php-ads-sdk/issues)MITPHPPHP ^7.3 || ^8.0

Since Mar 27Pushed 2y ago9 watchersCompare

[ Source](https://github.com/hborras/twitter-php-ads-sdk)[ Packagist](https://packagist.org/packages/hborras/twitter-php-ads-sdk)[ RSS](/packages/hborras-twitter-php-ads-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (50)Used By (0)

Getting Started [![Build Status](https://camo.githubusercontent.com/9458c33a6a7b35b5f4fa7c121d57dfd1fa6d5d314f6b54d86c9d8c802c5758a5/68747470733a2f2f7472617669732d63692e6f72672f68626f727261732f747769747465722d7068702d6164732d73646b2e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/9458c33a6a7b35b5f4fa7c121d57dfd1fa6d5d314f6b54d86c9d8c802c5758a5/68747470733a2f2f7472617669732d63692e6f72672f68626f727261732f747769747465722d7068702d6164732d73646b2e7376673f6272616e63683d6d6173746572) [![Scrutinizer Status](https://camo.githubusercontent.com/7ee305d3c4fe4c89dfd9ae4302d57aa2b72ecc835cc774bf5c5e72b910568b30/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f68626f727261732f747769747465722d7068702d6164732d73646b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://camo.githubusercontent.com/7ee305d3c4fe4c89dfd9ae4302d57aa2b72ecc835cc774bf5c5e72b910568b30/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f68626f727261732f747769747465722d7068702d6164732d73646b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#getting-started--)

### Installation

[](#installation)

```
# installing the latest signed release
composer require hborras/twitter-php-ads-sdk
```

### Quick Start

[](#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

$fundingInstruments = $account->getFundingInstruments();
$fundingInstrument = $fundingInstruments->getCollection()[0];

$campaign = new Campaign();
$campaign->setFundingInstrumentId($fundingInstrument->getId());
$campaign->setDailyBudgetAmountLocalMicro(1000000);
$campaign->setName("My first campaign: ");
$campaign->setEntityStatus('PAUSED');
$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
---------------

[](#field-constants)

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

Development
-----------

[](#development)

If you’d like to contribute to the project or try an unreleased development version of this project locally, you can do so quite easily by following the examples below.

```
# clone the repository
git clone git@github.com:hborras/twitter-php-ads-sdk.git
cd twitter-php-ads-sdk

# install dependencies
composer install
```

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2019 Hector Borras

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

target:target:

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 92.7% 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

Every ~58 days

Recently: every ~107 days

Total

42

Last Release

1298d ago

Major Versions

v6.0.4 → v7.0.02020-08-24

v7.0.0 → 8.0.02021-02-07

8.0.0 → v9.x-dev2021-08-23

v9.0.1 → v10.0.02022-03-21

v10.0.0 → V11.0.02022-10-28

PHP version history (4 changes)v0.1PHP &gt;=5.5.0

3.0.x-devPHP &gt;=5.6.0

v4.x-devPHP &gt;=7.1

8.0.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/37fffb15e29eff64cf5d3b43d0522fbc1a178aaafa712a6a51b28e21e89c32f0?d=identicon)[hborras](/maintainers/hborras)

---

Top Contributors

[![hborras](https://avatars.githubusercontent.com/u/2531844?v=4)](https://github.com/hborras "hborras (178 commits)")[![regiszanandrea](https://avatars.githubusercontent.com/u/2692748?v=4)](https://github.com/regiszanandrea "regiszanandrea (6 commits)")[![Blackburn29](https://avatars.githubusercontent.com/u/1065472?v=4)](https://github.com/Blackburn29 "Blackburn29 (2 commits)")[![timothyasp](https://avatars.githubusercontent.com/u/707699?v=4)](https://github.com/timothyasp "timothyasp (2 commits)")[![n-gibs](https://avatars.githubusercontent.com/u/26901936?v=4)](https://github.com/n-gibs "n-gibs (1 commits)")[![mmccaff](https://avatars.githubusercontent.com/u/1039597?v=4)](https://github.com/mmccaff "mmccaff (1 commits)")[![bheddens](https://avatars.githubusercontent.com/u/23571957?v=4)](https://github.com/bheddens "bheddens (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

phpsdksdk-phptwitte-adstwittertwitter-apiapirestadsoauthtwittersocialTwitter APITwitter oAuth

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hborras-twitter-php-ads-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/hborras-twitter-php-ads-sdk/health.svg)](https://phpackages.com/packages/hborras-twitter-php-ads-sdk)
```

###  Alternatives

[abraham/twitteroauth

The most popular PHP library for use with the Twitter OAuth REST API.

4.3k15.9M128](/packages/abraham-twitteroauth)[zoonman/linkedin-api-php-client

LinkedIn API PHP SDK with OAuth 2.0 &amp; CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.

127704.0k](/packages/zoonman-linkedin-api-php-client)

PHPackages © 2026

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