PHP code example of mailerlite / mailerlite-php
1. Go to this page and download the library: Download mailerlite/mailerlite-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/ */
mailerlite / mailerlite-php example snippets
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$data = [
'email' => '[email protected] ',
];
$response = $mailerLite->subscribers->create($data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$subscriberId = '123';
$response = $mailerLite->subscribers->find($subscriberId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->subscribers->get();
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$subscriberId = '123',
$data = [
'fields' => [
'name' => 'Example',
],
];
$response = $mailerLite->subscribers->update($subscriberId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$subscriberId = '123';
$response = $mailerLite->subscribers->delete($subscriberId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$data = [
'type' => 'regular',
'name' => 'My new campaign',
'language_id' => 10,
'emails' => [
[
'subject' => 'My new email',
'from_name' => 'me',
'from' => '[email protected] ',
'content' => 'Hello World!',
]
],
'filter' => [],
];
$response = $mailerLite->campaigns->create($data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$campaignId = '123';
$response = $mailerLite->campaigns->find($campaignId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$data = [
'filter' => ['status' => 'sent'],
];
$response = $mailerLite->campaigns->get($data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$campaignId = '123';
$data = [
'name' => 'Changed campaign name',
'emails' => [
[
'subject' => 'Changed email subject',
'from_name' => 'Changed from name',
'from' => '[email protected] ',
]
],
];
$response = $mailerLite->campaigns->update($campaignId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$campaignId = '123';
$response = $mailerLite->campaigns->delete($campaignId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$campaignId = '123';
$data = [
'delivery' => 'instant',
];
$response = $mailerLite->campaigns->schedule($campaignId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$campaignId = '123';
$response = $mailerLite->campaigns->cancel($campaignId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$campaignId = '123';
$data = [
'type' => 'opened',
];
$response = $mailerLite->campaigns->getSubscriberActivity($campaignId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$data = [
"name" => "New group",
];
$response = $mailerLite->groups->create($data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$groupId = '123';
$response = $mailerLite->groups->find($groupId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->groups->get();
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$groupId = '123';
$data = [
"name" => "Updated name",
];
$response = $mailerLite->groups->update($groupId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$groupId = '123';
$response = $mailerLite->groups->delete($groupId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$groupId = '123';
$response = $mailerLite->groups->getSubscribers($groupId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$groupId = '123';
$subscriberId = '456';
$response = $mailerLite->groups->assignSubscriber($groupId, $subscriberId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$groupId = '123';
$subscriberId = '456';
$response = $mailerLite->groups->unAssignSubscriber($groupId, $subscriberId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->segments->get();
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$segmentId = '123';
$data = [
"name" => "Updated name",
];
$response = $mailerLite->segments->update($segmentId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$segmentId = '123';
$response = $mailerLite->segments->delete($segmentId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$segmentId = '123';
$response = $mailerLite->segments->getSubscribers($segmentId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$data = [
"name" => "New field",
"type" => "text",
];
$response = $mailerLite->fields->create($data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->fields->get();
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$fieldId = '123';
$data = [
"name" => "Updated name",
];
$response = $mailerLite->fields->update($fieldId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$fieldId = '123';
$response = $mailerLite->fields->delete($fieldId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->forms->get('popup', []);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$formId = '123';
$response = $mailerLite->forms->find($formId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$formId = '123';
$data = [
"name" => "Updated name",
];
$response = $mailerLite->forms->update($formId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$formId = '123';
$response = $mailerLite->forms->delete($formId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$formId = '123';
$response = $mailerLite->forms->getSignups($formId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->automations->get([]);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$automationId = '123';
$response = $mailerLite->automations->find($automationId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$automationId = '123';
$data = [
'filter' => [
'status' => 'active',
],
];
$response = $mailerLite->automations->activity($automationId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$data = [
"name" => "Name",
"events" => ["subscriber.created"],
"url": "https://www.cartwright.info/eligendi-soluta-corporis-in-quod-ullam",
];
$response = $mailerLite->webhooks->create($data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->webhooks->get([]);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$webhookId = '123';
$response = $mailerLite->webhooks->find($webhookId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$webhookId = '123';
$data = [
"name" => "Updated name",
];
$response = $mailerLite->webhooks->update($webhookId, $data);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$webhookId = '123';
$response = $mailerLite->webhooks->delete($webhookId);
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->campaignLanguages->get();
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$response = $mailerLite->timezones->get();
use MailerLite\MailerLite;
$mailerLite = new MailerLite(['api_key' => 'key']);
$data = [
'requests' => [
[
'method' => 'post',
'path' => 'api/subscribers',
'body' => [
'email' => '[email protected] '
]
]
]
];
$response = $mailerLite->batches->send($data);
bash
composer
bash
$ composer