Learn more about how to download and implement our PHP API Integration Library to your own project.

Overview - what this Library is?

We want to provide our clients a way to use our system however they like. That is why we have introduced the Integration Libraries - a group of functions and declarations to help you implement our API to your system.

Instalation

To install our library you can use composer package manager by running

composer require elastic-email/web-api-client;

The source code is available also on our github if you wish to download the library manually.

How to start working with the Library on your project

If your project is using autoload (or framework that your are using does, like for example Symfony), you can just elastic email namespaces. To start you can just add 

use ElasticEmailClient\ElasticClient as Client;
use ElasticEmailClient\ApiConfiguration as Configuration; 

and create instance of ElasticEmail client

$configuration = new Configuration([
‘apiUrl’ => ‘https://api.elasticemail.com,
‘apiKey’ => ‘yourapikey
]);
$client = new Client($configuration);

Now $client has access to all categories and their methods used in our API

Some basic API calls made using this Library

Sending a merged email to multiple recipients, provided as an attachment:

<?php
    use ElasticEmailClient\ElasticClient as Client;
    use ElasticEmailClient\ApiConfiguration as Configuration;
$configuration = new Configuration([
‘apiUrl’ => ‘https://api.elasticemail.com,
‘apiKey’ => ‘yourapikey
]);
$client = new Client($configuration);
try {
$resp = $client->EEemail->Send(
“Subject”,
from@email.com”,
“Plain text email content”,
“HTML email content”,
[array, of, paths, to, attachments]
);
} catch (Exception $e) {
 throw new \Exception(e);
};

An example of loading info about your own account and displaying the price per email:

<?php
    use ElasticEmailClient\ElasticClient as Client;
    use ElasticEmailClient\ApiConfiguration as Configuration;
$configuration = new Configuration([
‘apiUrl’ => ‘https://api.elasticemail.com,
‘apiKey’ => ‘yourapikey
]);
$client = new Client($configuration);
try {
$acc = $client->EEaccount->Load();
} catch (Exception $e) {
 throw new \Exception(e);
};

One of many ways to save your contacts:

<?php
    use ElasticEmailClient\ElasticClient as Client;
    use ElasticEmailClient\ApiConfiguration as Configuration;
$configuration = new Configuration([
‘apiUrl’ => ‘https://api.elasticemail.com,
‘apiKey’ => ‘yourapikey
]);
$client = new Client($configuration);
try {
$client->EEcontact->QuickAdd([ "test1@test.com", "test2@test.com" ]);
}catch (Exception $e) {
 throw new \Exception(e);
};


If you like this article, share it with friends:
Share on Facebook
Facebook
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Ready to get started?

Tens of thousands of companies around the world are using Elastic Email to send their emails. Sign up now and join them for free!

Get set up in 2 minutes. No credit card required.