PHP API Integration Library

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

};
    • Related Articles

    • Integration Libraries

      Check out our integration libraries and code examples for HTTP API. API Integration Libraries C# (requires Newtonsoft's JSON) PHP (requires dependencies) PHP (full bundle) Â Java JavaScript (es6, requires dependencies) Â JavaScript (full bundle) ...
    • How to integrate Java API library

      Learn more about how to download and implement our Java API Integration Library to your system. 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 ...
    • How to integrate Python API library

      Learn more about how to download and implement our Python API Integration Library to your system. 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 ...
    • How to integrate C# library

      Learn more about how to download and implement our C# 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 ...
    • Howto install FFmpeg-PHP

      wget http://oratoronline.com/how2/video_share_modules/source_directory/ffmpeg/ffmpeg-php-0.5.1.tbz2 tar -xjvf ffmpeg-php-0.5.1.tbz2 ; cd ffmpeg-php-0.5.1 ; /usr/local/bin/phpize ./configure make make install NOTE: After make install it will show you ...