PHPackages                             pathak-vikash/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. pathak-vikash/twitter-php-ads-sdk

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

pathak-vikash/twitter-php-ads-sdk
=================================

A Twitter supported and maintained Ads API SDK for PHP

v11.0.0(3y ago)010.8k↓18.8%MITPHPPHP ^7.3 || ^8.0

Since Sep 28Pushed 3y agoCompare

[ Source](https://github.com/pathak-vikash/twitter-php-ads-sdk)[ Packagist](https://packagist.org/packages/pathak-vikash/twitter-php-ads-sdk)[ RSS](/packages/pathak-vikash-twitter-php-ads-sdk/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (3)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

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

1374d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8e152b010d506dd10815f88539bd4b6c9c5e114a70efb4c7e2620423a05f9eb?d=identicon)[pathak-vikash](/maintainers/pathak-vikash)

---

Top Contributors

[![hborras](https://avatars.githubusercontent.com/u/2531844?v=4)](https://github.com/hborras "hborras (177 commits)")[![pathak-vikash](https://avatars.githubusercontent.com/u/4647499?v=4)](https://github.com/pathak-vikash "pathak-vikash (6 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)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![mmccaff](https://avatars.githubusercontent.com/u/1039597?v=4)](https://github.com/mmccaff "mmccaff (1 commits)")[![n-gibs](https://avatars.githubusercontent.com/u/26901936?v=4)](https://github.com/n-gibs "n-gibs (1 commits)")[![bheddens](https://avatars.githubusercontent.com/u/23571957?v=4)](https://github.com/bheddens "bheddens (1 commits)")

---

Tags

apirestadsoauthtwittersocialTwitter APITwitter oAuth

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[abraham/twitteroauth

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

4.3k16.6M135](/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.

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

PHPackages © 2026

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