dreamcampaigns/managesend-php
PHP client library for the DreamCampaigns (Managesend) API. Authenticate with API key/secret and send transactional “Smart” emails via the REST client. Install with Composer or manually with the included autoloader. Supports PHP 5.3–7.4.
A PHP library implementing the complete functionality of the DreamCampaigns API. A complete suites of marketing tools for your business or website.
This library supports the following PHP implementations:
You can install managesend-php via composer or by downloading the source.
managesend-php is available on Packagist as the
dreamcampaigns/managesend-php package.
If you use Composer, you can run the following command from the root of your project to install:
composer require dreamcampaigns/managesend-php
If youn't use Composer you can simply download the library and include it in your project.
After you have installed the library, if you need an autoloader, simply include the managesend-php autoload class, as follows:
require_once __DIR__ . '/../managesend-php/autoLoader/autoload.php';
The DreamCampaigns API uses Basic authentication using an API key and API secret.
// Send a Smart email using DreamCampaigns's REST API and PHP
<?php
$apiKey = "ACXXXXXX"; // Your Account/Client API Key from https://login.managesend.com/myaccount/apikeys
$apiSecret = "YXYXYX"; // Your Account/Client API Secret from https://login.managesend.com/myaccount/apikeys
$clientId = "a6hsgw74dw0001om4yrgfen8";
$restClient = new \Managesend\RestClient($apiKey, $apiSecret, $clientId);
$result = $restClient->transactional()->sendSmartEmail("c5is8tltkk00018k9ype5lg741",array(
"toEmail"=>"joe@example.com",
"toName"=>"Joe Smith",
"data"=>array("promoCode"=>"XYZ"),
));
$newEmail = $result->getData();
//your IDE should auto generate all available getters for each call & results
print $newEmail->getMessageId();
print $newEmail->getStatus();
//or if you preffer arrays
print_r($newEmail->toArray());
//or you can get the response, where you can get all available data & headers as array
$response = $result->getResponse();
// Send a Dynamic SMS using DreamCampaigns's REST API and PHP
<?php
$apiKey = "ACXXXXXX"; // Your Account API Key from https://login.managesend.com/myaccount/apikeys
$apiSecret = "YXYXYX"; // Your Account API Secret from https://login.managesend.com/myaccount/apikeys
//if you are using your account level api keys you can set the client ids for each call.
$restClient = new \Managesend\RestClient($apiKey, $apiSecret);
$result = $restClient->setClientId("c5is8tltkk00018k9ype5lg741")->transactional()->sendDynamicSms("c5is8tltkk00018k9ype5lg741",array(
"toNumber"=>"+1234567891",
"content"=>"Hello Joe, your password has been reset.",
));
$newSms = $result->getData();
print $newEmail->getMessageId();
<?php
$result = $restClient->emailCampaign()->getCampaignsSent();
$campaigns = $result->getData();
foreach ($campaigns as $campaign){
print $campaign->getSentDate();
}
If you're using .env, you can set your API credentials in your .env.
MANAGESEND_TOKEN_KEY=ACXXXXXX
MANAGESEND_TOKEN_SECRET=YXYXYX
MANAGESEND_CLIENT_ID=c5is8tltkk00018k9ype5lg741
<?php
$restClient = new \Managesend\RestClient();
$result = $restClient->lists()->getSubscriberList("joe@example.com");
Samples for creating or accessing all resources can be found in the examples directory.
For more details you can reffer to the DreamCampaigns API documentations
How can I help you explore Laravel packages today?