PHP API Integration Library

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

};
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to integrate Java API library

Learn more about how to download and implement our Java API Integration Library to your system....

How to integrate C# library

Learn more about how to download and implement our C# Integration Library to your own project....

How to integrate Python API library

Learn more about how to download and implement our Python API Integration Library to your system....

Integration Libraries

Check out our integration libraries and code examples for HTTP API. API Integration Libraries...