1. Go to this page and download the library: Download sendigram/ems-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/ */
sendigram / ems-php example snippets
use Sendigram\Ems\Client\EmsClient;
$client = new EmsClient('YOUR_API_TOKEN');
// List the first page of contacts
$list = $client->contacts->list(perPage: 50);
foreach ($list->data as $contact) {
echo $contact->email, "\n";
}
// Fetch one
$contact = $client->contacts->get(42);
// Create
$created = $client->contacts->create(
email: '[email protected]',
firstName: 'John',
lastName: 'Doe',
);
// Update (only provided fields are touched)
$updated = $client->contacts->update(42, firstName: 'Jane');
// Upsert by email
$result = $client->contacts->upsert(email: '[email protected]', firstName: 'Alice');
$result->created; // true on HTTP 201, false on HTTP 200
$result->contact; // typed Contact
// Delete
$client->contacts->delete(42);
$client->contacts->deleteByEmail('[email protected]');
// Iterate every page lazily
foreach ($client->contacts->iterate(perPage: 100) as $contact) {
// …
}
use Sendigram\Ems\Client\Configuration;
use Sendigram\Ems\Client\EmsClient;
$client = new EmsClient(
Configuration::default('YOUR_API_TOKEN')
->withBaseUrl('https://ems.sendigram.com/open-api/v1/')
->withTimeout(60)
->withUserAgent('my-app/1.0'),
);