Giter Site home page Giter Site logo

php-klaviyo's Introduction

Klaviyo PHP SDK + GET and PUT

This is a fork of the official Klaviyo PHP API that also adds in GET and PUT functionality from robwittman/php-klaviyo. The Guzzle requirement of robwittman was removed by borrowing from the Order Desk PHP Client. It provides a minimal-abstraction wrapper for the track, identify, metrics, profiles, lists (v1 and v2), campaigns, and templates APIs all from the same class.

Table of Contents

  1. Metrics
  2. Profiles
  3. Lists
  4. Lists v2
  5. Campaigns
  6. Templates
  7. Track
  8. Identify

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "page"  => 1,
    "count" => 100
);
$result = $klaviyo->get("metrics", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "since" => 1400656845,
    "count" => 100,
    "sort"  => "asc"
);
$result = $klaviyo->get("metrics/timeline", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "since" => 1400656845,
    "count" => 100,
    "sort"  => "asc"
);
$result = $klaviyo->get("metric/{{METRIC_ID}}/timeline", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "start_date"  => 2015-01-01,
    "end_date"    => 2015-01-31,
    "unit"        => "week",
    "measurement" => '["sum","ItemCount"]',
    "where"       => '[["ItemCount","=",5]]',
//  "by"          => urlencode('Accepts Marketing'),
    "count" => 100
);
$result = $klaviyo->get("metric/{{METRIC_ID}}/export", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->get("person/{{PERSON_ID}}");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
   '$id'                => 'dqQnNW',
   '$email'             => '[email protected]',
   '$first_name'        => 'George',
   '$last_name'         => 'Washington',
   '$phone_number'      => '555-555-5555',
   '$title'             => 'Ex-president',
   '$organization'      => 'U.S. Government',
   '$city'              => 'Mount Vernon',
   '$region'            => 'Virginia',
   '$country'           => 'US',
   '$zip'               => '22121',
   '$image'             => 'http://media.clarkart.edu/Web_medium_images/1955.16.jpg',
   '$timezone'          => 'US/Eastern',
   'favorite_ice_cream' => 'vanilla'
);
$result = $klaviyo->put("person/{{PERSON_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "since" => 1400656845,
    "count" => 100,
    "sort"  => "asc"
);
$result = $klaviyo->get("person/{{PERSON_ID}}/metrics/timeline", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "since" => 1400656845,
    "count" => 100,
    "sort"  => "asc"
);
$result = $klaviyo->get("person/{{PERSON_ID}}/metric/{{METRIC_ID}}/timeline", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$result = $klaviyo->get("people");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "type"  => "segment",
    "page"  => "1",
    "count" => "100"
);
$result = $klaviyo->get("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name"        => "My New List",
    "list_type"   => "standard"
);
$result = $klaviyo->post("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->get("list/{{LIST_ID}}");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name" => "My New List Name"
);
$result = $klaviyo->put("list/{{LIST_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->delete("list/{{LIST_ID}}");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email" => '["[email protected]","[email protected]"]'
);
$result = $klaviyo->get("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email" => '["[email protected]","[email protected]"]'
);
$result = $klaviyo->get("segment/{{SEGMENT_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email"          => "[email protected]",
    "properties"     => '{ "$first_name" : "George", "Birthday" : "02/22/1732" }',
    "confirm_optin"  => true
);
$result = $klaviyo->post("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "batch"          => '[ { "email" : "[email protected]", "properties" : { "$first_name" : "George", "Birthday" : "02/22/1732" } }, { "email" : "[email protected]" } ]',
    "confirm_optin"  => true
);
$result = $klaviyo->post("list/{{LIST_ID}}/members/batch", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "batch" => '[ { "email" : "[email protected]" }, { "email" : "[email protected]" } ]'
);
$result = $klaviyo->delete("list/{{LIST_ID}}/members/batch", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email"       => "[email protected]",
    "timestamp"   => 1400656845
);
$result = $klaviyo->post("list/{{LIST_ID}}/members/exclude", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "reason"   => "unsubscribe",
    "sort"     => "desc"
);
$result = $klaviyo->get("list/{{LIST_ID}}/exclusions", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "reason"   => "unsubscribe",
    "sort"     => "desc"
);
$result = $klaviyo->get("people/exclusions", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email"       => "[email protected]",
    "timestamp"   => 1400656845
);
$result = $klaviyo->post("people/exclusions", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->post("segment/{{SEGMENT_ID}}/get-members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->post("list/{{LIST_ID}}/get-members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->post("list/{{LIST_ID}}/get-list-subscriptions", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->get("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->post("people/exclusions", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "list_name" => "my new list name",
    "version"   => 2
);
$result = $klaviyo->post("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->get("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->get("list/{{LIST_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "list_name" => "my new list name",
    "version"   => 2
);
$result = $klaviyo->put("list/{{LIST_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->delete("list/{{LIST_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "profiles" => '[ { "email": "[email protected]", "example_property": "valueA" }, { "email": "[email protected]", "example_property": "valueB" } ]',
    "version"   => 2
);
$result = $klaviyo->post("list/{{LIST_ID}}/subscribe", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "emails" => '["[email protected]", "[email protected]"]',
    "version"   => 2
);
$result = $klaviyo->get("list/{{LIST_ID}}/subscribe", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "emails" => '["[email protected]", "[email protected]"]',
    "version"   => 2
);
$result = $klaviyo->delete("list/{{LIST_ID}}/subscribe", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "profiles" => '[ { "email": "[email protected]", "example_property": "valueA" }, { "email": "[email protected]", "example_property": "valueB" } ]',
    "version"   => 2
);
$result = $klaviyo->post("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "emails" => '["[email protected]", "[email protected]"]',
    "version"   => 2
);
$result = $klaviyo->delete("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "marker" => 123456,
    "version"   => 2
);
$result = $klaviyo->get("list/{{LIST_ID}}/exclusions/all", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$result = array(
    "marker" => 1
);

while (array_key_exists("marker", $result)) {
    $args = array(
        "marker" => $result["marker"],
        "version"   => 2
    );
    $result = $klaviyo->get("list/{{LIST_ID or SEGMENT_ID}}/members/all", $args);
    echo "<pre>" . print_r($result, 1) . "</pre>";
}
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "emails" => '["[email protected]", "[email protected]"]',
    "version"   => 2
);
$result = $klaviyo->get("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "page"  => 1,
    "count" => 100
);
$result = $klaviyo->get("campaigns", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "list_id"              => "erRoOX",
    "template_id"          => "gtTqQZ",
    "from_email"           => "[email protected]",
    "from_name"            => "George Washington",
    "subject"              => "Company Monthly Newsletter",
    "name"                 => "Campaign Name",
    "use_smart_sending"    => true,
    "add_google_analytics" => true
);
$result = $klaviyo->post("campaigns", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->get("campaign/{{CAMPAIGN_ID}}");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "list_id"              => "erRoOX",
    "template_id"          => "gtTqQZ",
    "from_email"           => "[email protected]",
    "from_name"            => "George Washington",
    "subject"              => "Company Monthly Newsletter",
    "name"                 => "Campaign Name",
    "use_smart_sending"    => true,
    "add_google_analytics" => true
);
$result = $klaviyo->put("campaign/{{CAMPAIGN_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->post("campaign/{{CAMPAIGN_ID}}/send");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "send_time"   => "2013-06-14 00:00:00"
);
$result = $klaviyo->post("campaign/{{CAMPAIGN_ID}}/schedule", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->post("campaign/{{CAMPAIGN_ID}}/cancel", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name"     => "Cloned Campaign",
    "list_id"  => "erRoOX"
);
$result = $klaviyo->post("campaign/{{CAMPAIGN_ID}}/clone", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "count"    => 25000,
    "sort"     => "desc",
    "offset"   => "Z2VvcmdlLndhc2hpbmd0b25AZXhhbXBsZS5jb20=",
);
$result = $klaviyo->get("campaign/{{CAMPAIGN_ID}}/recipients", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->get("email-templates", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name" => "My New Template",
    "html" => "<html><body><p>This is an email for {{ email }}.</p></body></html>"
);
$result = $klaviyo->post("email-templates", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name" => "My New Template",
    "html" => "<html><body><p>This is an email for {{ email }}.</p></body></html>"
);
$result = $klaviyo->put("email-template/{{TEMPLATE_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->delete("email-template/{{TEMPLATE_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name" => "My Cloned Template"
);
$result = $klaviyo->post("email-template/{{TEMPLATE_ID}}/clone", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "context" => '{ "name" : "George Washington", "notifcation_count" : 10 }',
);
$result = $klaviyo->post("email-template/{{TEMPLATE_ID}}/render", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "from_email" => "[email protected]",
    "from_name"  => "George Washington",
    "subject"    => "Company Monthly Newsletter",
    "context"    => '{ "name" : "George Washington", "notifcation_count" : 10 }'
);
$result = $klaviyo->post("email-template/{{TEMPLATE_ID}}/send", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$token = "ABC123";
$klaviyo = new Klaviyo(null, $token);
$event = "Elected President";
$customer_properties = array(
    '$email' => "[email protected]"
);
$properties = array(
    "PreviouslyVicePresident" => true,
    "YearElected"             => 1801,
    "VicePresidents"          => ["Aaron Burr", "George Clinton"]
);
$time = 1537057291;
$result = $klaviyo->tracker($event, $customer_properties, $properties, $time);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

However, since a GET request is being performed in the class, the following implementation is also supported:

<?php
include "Klaviyo.php";
$token = "ABC123";
$klaviyo = new Klaviyo(null, $token);
$args = array(
    "event" => "Elected President",
    "customer_properties" => array(
        '$email' => "[email protected]"
    ),
    "properties" => array(
        "PreviouslyVicePresident" => true,
        "YearElected"             => 1801,
        "VicePresidents"          => ["Aaron Burr", "George Clinton"],
        '$event_id'               => 10001234,
        '$value'                  => 11.25
    ),
    "time" => 1537057291
);
$result = $klaviyo->get("track", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

<?php
include "Klaviyo.php";
$token = "ABC123";
$klaviyo = new Klaviyo(null, $token);
$properties = array(
    '$id'           => 'dqQnNW',
    '$email'        => '[email protected]',
    '$first_name'   => 'George',
    '$last_name'    => 'Washington',
    '$phone_number' => '555-555-5555',
    '$title'        => 'Ex-president',
    '$organization' => 'U.S. Government',
    '$city'         => 'Mount Vernon',
    '$region'       => 'Virginia',
    '$country'      => 'US',
    '$zip'          => '22121',
    '$image'        => 'http://media.clarkart.edu/Web_medium_images/1955.16.jpg',
    "Plan"          => "Premium",
    "SignUpDate"    => "2016-05-01 10:10:00"
);
$result = $klaviyo->identify($properties);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

However, since a GET request is being performed in the class, the following implementation is also supported:

<?php
include "Klaviyo.php";
$token = "ABC123";
$klaviyo = new Klaviyo(null, $token);
$properties = array(
    '$id'           => 'dqQnNW',
    '$email'        => '[email protected]',
    '$first_name'   => 'George',
    '$last_name'    => 'Washington',
    '$phone_number' => '555-555-5555',
    '$title'        => 'Ex-president',
    '$organization' => 'U.S. Government',
    '$city'         => 'Mount Vernon',
    '$region'       => 'Virginia',
    '$country'      => 'US',
    '$zip'          => '22121',
    '$image'        => 'http://media.clarkart.edu/Web_medium_images/1955.16.jpg',
    "Plan"          => "Premium",
    "SignUpDate"    => "2016-05-01 10:10:00"
);
$result = $klaviyo->get("identify", $properties);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

php-klaviyo's People

Contributors

bialecki avatar bradleymellen avatar chris-ware avatar cykolln avatar dano-klaviyo avatar etienneroudeix avatar invertedfjord avatar jon-batscha avatar kamil-klasicki avatar loevgaard avatar mangoceylon2 avatar ogsmith avatar remstone7 avatar siddwarkhedkar avatar smoucka avatar summersab avatar syammohanmp avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

tobyberesford

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.