tbolner/twitter-php-ads-sdk
Composer 安装命令:
composer require tbolner/twitter-php-ads-sdk
包简介
A Twitter supported and maintained Ads API SDK for PHP
README 文档
README
This branch only modifies the version number from 9 to 11.
These changes are not implemented:
If you wish to implement some of those, then collaborators are welcome.
Packagist page for this version: - https://packagist.org/packages/tbolner/twitter-php-ads-sdk
Getting Started

Installation
# installing the latest signed release
composer require tbolner/twitter-php-ads-sdk
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
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' . . .
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
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: | https://travis-ci.org/hborras/twitter-php-ads-sdk |
|---|
| target: | https://scrutinizer-ci.com/g/hborras/twitter-php-ads-sdk |
|---|
tbolner/twitter-php-ads-sdk 适用场景与选型建议
tbolner/twitter-php-ads-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.02k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rest」 「api」 「oauth」 「twitter」 「social」 「Twitter API」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tbolner/twitter-php-ads-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tbolner/twitter-php-ads-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tbolner/twitter-php-ads-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WeChat OAuth SDK
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Library for ORCID web services
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
统计信息
- 总下载量: 7.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-16