PHP code example of dreamcampaigns / managesend-php

1. Go to this page and download the library: Download dreamcampaigns/managesend-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dreamcampaigns / managesend-php example snippets




// Send a Smart email using DreamCampaigns's REST API and 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"=>"[email protected]",
    "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

$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();


$result = $restClient->emailCampaign()->getCampaignsSent();
$campaigns = $result->getData();
foreach ($campaigns as $campaign){
    print $campaign->getSentDate();
}


$restClient = new \Managesend\RestClient();
$result = $restClient->lists()->getSubscriberList("[email protected]");

composer