sohaibilyas/sedotmp-php
最新稳定版本:v0.2.6
Composer 安装命令:
composer require sohaibilyas/sedotmp-php
包简介
PHP SDK for SedoTMP - Sedo Traffic Monetization Platform (sedotmp.com).
README 文档
README
A simple PHP SDK for interacting with SedoTMP - Sedo Traffic Monetization Platform (sedotmp.com).
Requires PHP 8.2+
Installation
Install via Composer:
composer require sohaibilyas/sedotmp-php
Usage
Getting Started
use SohaibIlyas\SedoTmp\SedoTmp; $client = new SedoTmp('your-client-id', 'your-client-secret');
Authentication
Getting a New Access Token
Call getAccessToken() to fetch and cache an access token:
$client = new SedoTmp('your-client-id', 'your-client-secret'); $token = $client->getAccessToken(); $categories = $client->content()->getCategories(); $campaigns = $client->platform()->getContentCampaigns(0);
Using an Existing Access Token
If you already have a token (e.g., from cache or session), use setAccessToken() to avoid making an authentication request:
$client = new SedoTmp('your-client-id', 'your-client-secret'); $client->setAccessToken('your-existing-token'); $categories = $client->content()->getCategories();
Complete Example with Token Caching
$client = new SedoTmp('your-client-id', 'your-client-secret'); if (isset($_SESSION['sedo_token'])) { $client->setAccessToken($_SESSION['sedo_token']); } else { $token = $client->getAccessToken(); $_SESSION['sedo_token'] = $token; } $categories = $client->content()->getCategories(); $campaigns = $client->platform()->getContentCampaigns(0);
Content API
Get Categories
$categories = $client->content()->getCategories();
Platform API
Get Content Campaigns
Retrieve content campaigns with pagination:
$campaigns = $client->platform()->getContentCampaigns(page: 0);
Get Single Content Campaign
Retrieve a specific content campaign by ID:
$campaign = $client->platform()->getContentCampaign('310a2938-6824-4bf9-afdf-994c3a673864');
Create Content Campaign
Create a new content campaign:
$campaignData = [ 'publishDomainName' => 'sohaibilyas.com', 'article' => [ 'country' => 'US', 'locale' => 'en', 'featuredImage' => [ 'generate' => true ], 'title' => 'Summer vacation', 'excerpt' => 'The best summer vacation deals', 'topics' => ['Summer vacation'], 'categoryId' => '2e5c8fbb-f078-498b-82e5-d45263e21f67', 'type' => 'CreateArticle', ], 'campaign' => [ 'name' => 'Summer vacation', 'trackingData' => [ 'trafficSource' => 'META', 'trackingSettings' => [ 'type' => 'PixelMetaTrackingSettings', 'pixelMetaPixelId' => '012345678910', 'pixelMetaLandingPageEvent' => 'Subscribe', 'pixelMetaClickEvent' => 'Purchase' ], 'trackingMethod' => 'PIXEL' ], 'type' => 'CreateCampaign' ], ]; $result = $client->platform()->createContentCampaign($campaignData);
Get Campaign Report
Retrieve campaign report data with dimensions, filters, sorting, and pagination:
$report = $client->platform()->getCampaignReport( dimensions: ['DATE', 'HOUR', 'COUNTRY'], filter: [ 'startDate' => ['year' => 2024, 'month' => 1, 'day' => 1], 'endDate' => ['year' => 2024, 'month' => 1, 'day' => 31], 'campaignId' => '310a2938-6824-4bf9-afdf-994c3a673864', ], sort: 'CLICKS,asc', pagination: ['page' => 0, 'size' => 10] );
Available dimensions:
DATEHOURPARTNERCAMPAIGN_IDCOUNTRYDEVICE_TYPE
Available sort fields:
RELATED_LINKS_REQUESTSRELATED_LINKS_IMPRESSIONSRELATED_LINKS_CLICKSRELATED_LINKS_RPMAD_REQUESTSMATCHED_AD_REQUESTSAD_IMPRESSIONSIMPRESSIONSCLICKSCTRAD_CTRCPCAD_RPMCONVERSION_RATEREVENUEDATEHOURPARTNERCAMPAIGN_IDCOUNTRYDEVICE_TYPE
Pagination options:
Use page-based pagination:
$report = $client->platform()->getCampaignReport( pagination: ['page' => 0, 'size' => 10] );
Or use offset-based pagination:
$report = $client->platform()->getCampaignReport( pagination: ['offset' => 0, 'limit' => 100] );
Note: If neither startDate nor endDate is provided in the filter, they will default to yesterday's date.
Custom Configuration
You can optionally provide custom API version, base URL, and auth URL:
$client = new SedoTmp( 'your-client-id', 'your-client-secret', 'v1', 'https://custom-api.sedotmp.com', 'https://custom-auth.sedotmp.com/oauth/token' );
Development
Testing
All tests use mocked HTTP clients - no real API calls are made during testing.
Run unit tests using PEST:
composer test:unit
Run the entire test suite:
composer test
Code Quality
Keep a modern codebase with Pint:
composer lint
Run refactors using Rector:
composer refactor
Run static analysis using PHPStan:
composer test:types
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 83
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-23