PHP code example of yonoma / email-marketing

1. Go to this page and download the library: Download yonoma/email-marketing 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/ */

    

yonoma / email-marketing example snippets




$yonoma = new YonomaEmailMarketing\ApiClient('YOUR-API-KEY');

$response = $yonoma->groups->create([
  "group_name" => "New group"
]);

$response = $yonoma->groups->list();

$response = $yonoma->groups->retrieve('Group id');

$response = $yonoma->groups->update('A0SADFD6PJ',[
  "group_name" => "Updated group name"
]);

$response = $yonoma->groups->delete('Group id');

$response = $yonoma->tags->create([
  "tag_name" => "New tag"
]);

$response = $yonoma->tags->list();

$response = $yonoma->tags->retrieve('Tag id');

$response = $yonoma->tags->update('Tag id',[
  "tag_name" => "Updated tag name"
]);

$response = $yonoma->tags->delete('Tag id');

$response = $yonoma->contacts->create("Group id", [
  "email" => "[email protected]",
  "status" => "Subscribed" | "Unsubscribed",
  "data" => [
      "firstName" => "Contact",
      "lastName" => "One",
      "phone" => "1234567890",
      "address" => "123, NY street",
      "city" => "NY City",
      "state" => "NY",
      "country" => "US",
      "zipcode" => "10001"
  ]
]);

$response = $yonoma->contacts->update("Group id", "Contact id", [
  "status" => "Subscribed" | "Unsubscribed",
]);

$response = $yonoma->contacts->addTag("Contact id", [
  "tag_id" => "Tag id",
]);

$response = $yonoma->contacts->removeTag("Contact id", [
  "tag_id" => "Tag id",
]);