sohaibilyas / sedotmp-php
PHP SDK for SedoTMP - Sedo Traffic Monetization Platform (sedotmp.com).
Installs: 55
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/sohaibilyas/sedotmp-php
Requires
- php: ^8.2.0
- guzzlehttp/guzzle: ^7.10
Requires (Dev)
- laravel/pint: ^1.24.0
- peckphp/peck: ^0.1.3
- pestphp/pest: ^4.1.0
- pestphp/pest-plugin-type-coverage: ^4.0.2
- phpstan/phpstan: ^2.1.26
- rector/rector: ^2.1.7
- symfony/var-dumper: ^7.3.3
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.