collinped / aimtell-php
PHP SDK for Aimtell
Fund package maintenance!
collinped
Requires
- php: ^7.4|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpunit/phpunit: ^9.3
- vimeo/psalm: ^4.3
README
Aimtell offers a service for push notifications to users who give permission. This package allows for interfacing with Aimtell's backend API to manage your account.
Aimtell REST API Documentation
Installation
You can install the package via composer:
composer require collinped/aimtell-php
Usage
Quick Example
$aimtell = new Collinped\Aimtell($apiKey, $defaultSiteId, $whiteLabelId); $site = $aimtell->site() ->create([ 'name' => 'Sample Website', 'url' => 'collinped.com' ]); $campaigns = $aimtell->site($siteId) ->campaign() ->all(); $campaign = $aimtell->site($siteId) ->campaign() ->find($campaignId);
Authentication
- Get API Key
- Set API Key
- Get Default Site ID
- Set Default Site ID
- Get White Label ID
- Set White Label ID
Sites
- Get All Websites
- Get Website
- Get Website Code
- Add Website
- Update Website Details
- Get Website Settings
- Update Website Settings
- Update Website Package (Safari)
- Delete Website
- Get Website Keys
- Upsert Website Keys
Subscribers
- Get All Subscribers
- Get Subscriber
- Track Subscriber Attributes
- Track Subscriber Event
- Opt-Out Subscriber
Segments
- Get All Segments
- Get Segment
- Create Segment
- Update Segment
- Delete Segment
- Get Segment Counts Over Time (By Day)
Welcome Notification Campaign
- Get Welcome Notification
- Get Welcome Notification Campaign Results (By Day)
- Update Welcome Notification (Upsert)
Manual Campaigns
- Get All Manual Campaigns
- Get Manual Campaign
- Get Manual Campaign Clicks
- Get Manual Campaign Results (By Day)
- Create Manual Campaign
- Update Manual Campaign
- Delete Manual Campaign
Triggered Campaigns
- Get All Event Triggered Campaigns
- Get Event Triggered Campaign
- Get Event Triggered Campaign Results (By Day)
- Create Event Triggered Campaign
- Update Event Triggered Campaign
- Delete Event Triggered Campaign
RSS Campaigns
- Get All RSS Campaigns
- Get RSS Campaign
- Create RSS Campaign
- Update RSS Campaign
- Delete RSS Campaign
API Campaigns
- Get All API Campaigns
- Get API Campaign
- Get Event API Campaign Results (By Day)
Send Push Notifications
- Send a Push Notification
Authentication
Get API Key
$aimtell = $aimtell->getApiKey();
Set API Key
$aimtell = $aimtell->setApiKey($apiKey);
Get Default Site ID
$aimtell = $aimtell->getDefaultSiteId();
Set Default Site ID
$aimtell = $aimtell->setDefaultSiteId($defaultSiteId);
Get White Label ID
$aimtell = $aimtell->getWhiteLabelId();
Set White Label ID
$aimtell = $aimtell->setWhiteLabelId($whiteLabelId);
Sites
Get All Websites - Aimtell Docs
$websites = $aimtell->site() ->all();
Get Website - Aimtell Docs
$website = $aimtell->site() ->find($siteId);
Get Website Code - Aimtell Docs
$website = $aimtell->site($siteId) ->getCode();
Add Website - Aimtell Docs
$websites = $aimtell->site() ->create([ 'name' => 'Website Name', // Required 'url' => 'facebook.com' // Required ]);
Update Website Details - Aimtell Docs
$websites = $aimtell->site($siteId) ->update([ 'name' => 'Website Name', 'url' => 'facebook.com' 'icon' => 'imageUrl.jpg' ]);
Get Website Settings - Aimtell Docs
$websites = $aimtell->site($siteId) ->getSettings();
Update Website Settings - Aimtell Docs
$websites = $aimtell->site($siteId) ->updateSettings([ ... ]);
Update Website Package (Safari) - Aimtell Docs
$websites = $aimtell->site($siteId) ->updatePackage();
Delete Website - Aimtell Docs
$websites = $aimtell->site($siteId) ->delete();
Get Website Keys - Aimtell Docs
$websites = $aimtell->site($siteId) ->getKeys();
Upsert Website Keys - Aimtell Docs
$websites = $aimtell->site($siteId) ->upsertKeys([ ... ]);
Subscribers
Get All Subscribers - Aimtell Docs
$subscribers = $aimtell->site($siteId) ->subscriber() ->all();
Get Subscriber - Aimtell Docs
$subscriber = $aimtell->site($siteId) ->subscriber() ->find($subscriberId);
Track Subscriber Attribute - Aimtell Docs
$subscriber = $aimtell->site($siteId) ->subscriber($subscriberId) ->trackEvent([ 'first_name' => 'jeff' 'gender' => 'male' ]);
Track Subscriber Event - Aimtell Docs
$subscriber = $aimtell->site($siteId) ->subscriber($subscriberId) ->trackEvent([ 'category' => '' // Required 'action' => '', // Required 'label' => '', 'value' => 1.00 ]);
Opt-Out Subscriber - Aimtell Docs
$subscriber = $aimtell->site($siteId) ->subscriber($subscriberId) ->optOut();
Segments
Get All Segments - Aimtell Docs
$segments = $aimtell->site($siteId) ->segment() ->all();
Get Segment - Aimtell Docs
$segment = $aimtell->site($siteId) ->segment() ->find($segmentId);
Create Segment - Aimtell Docs
$segment = $aimtell->site($siteId) ->segment() ->create([ 'name' => 'Segment Name' 'definition' => 'city==Irvine' // See Aimtell Docs ]);
Update Segment - Aimtell Docs
$segment = $aimtell->site($siteId) ->segment($segmentId) ->update([ 'name' => 'Segment Name' 'definition' => 'city==Irvine' // See Aimtell Docs ]);
Delete Segment - Aimtell Docs
$segment = $aimtell->site($siteId) ->segment($segmentId) ->delete();
Get Segment Counts Over Time (By Day) - Aimtell Docs
$results = $aimtell->site($siteId) ->segment($segmentId) ->getResultsByDate([ 'startDate' => '1/1/2020', 'endDate' => '1/30/2020' ]);
Welcome Notifications
Get Welcome Notification - Aimtell Docs
$welcomeNotification = $aimtell->site($siteId) ->welcomeNotification() ->get();
Get Welcome Notification Results (By Day) - Aimtell Docs
$results = $aimtell->site($siteId) ->welcomeNotification() ->getResultsByDate([ 'startDate' => '1/1/2020', 'endDate' => '1/30/2020' ]);
Update Welcome Notification (Upsert) - Aimtell Docs
$welcomeNotification = $aimtell->site($siteId) ->welcomeNotification() ->update([ 'title' => 'Welcome Title', // Required 'body' => 'Welcome body', // Required 'link' => 'http://facebook.com', // Required 'status' => '1' // Required - 0 = Draft, 1 = Active ]);
Manual Campaigns
Get All Manual Campaigns - Aimtell Docs
$campaigns = $aimtell->site($siteId) ->campaign() ->all();
Get Manual Campaign - Aimtell Docs
$campaign = $aimtell->site($siteId) ->campaign() ->find($campaignId);
Get Manual Campaign Clicks - Aimtell Docs
$campaign = $aimtell->site($siteId) ->campaign($campaignId) ->getClicks();
Get Manual Campaign Results (By Day) - Aimtell Docs
$campaign = $aimtell->site($siteId) ->campaign($campaignId) ->getResultsByDate([ 'startDate' => '01/01/2020', 'endDate' => '02/15/2020', ]);
Create Manual Campaign - Aimtell Docs
$campaign = $aimtell->site($siteId) ->campaign($campaignId) ->create([ 'name' => 'Campaign Name', // Required 'title' => 'Campaign Title', ... ]);
Update Manual Campaign - Aimtell Docs
$campaign = $aimtell->site($siteId) ->campaign($campaignId) ->update([ 'name' => 'New Campaign Name', 'title' => 'New Campaign Title', ... ]);
Delete Manual Campaign - Aimtell Docs
$campaign = $aimtell->site($siteId) ->campaign($campaignId) ->delete();
Send Push Notifications
Send a Push Notification - Aimtell Docs
$notification = $aimtell->site($siteId) ->push() ->title('Sample Notification') ->message('Here is your sample message') ->link('https://www.laravel.com') ->toSubscriber($subscriberId) ->withButton([ 'link' => 'sampleUrl', 'title' => 'Sample Title 1', ]) ->withButton([ 'link' => 'sampleUrl2', 'title' => 'Sample Title 2', ]) ->send();
Testing
composer test
Todo
- A/B Tests for Manual Campaigns
- Create Manual Campaign (Batch)
- Update Manual Campaign (Batch)
- Delete Manual Campaign (Batch)
- Create Event Triggered Campaign (Batch)
- Update Event Triggered Campaign (Batch)
- Delete Event Triggered Campaign (Batch)
- Get Notification Logs
- Get Attributes Logs
- Get Pageview Logs
- Get Event Logs
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.