PHP code example of klaviyo / sdk
1. Go to this page and download the library: Download klaviyo/sdk 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/ */
klaviyo / sdk example snippets
Klaviyo\Client;
$client = new Client(
'YOUR_API_KEY',
$num_retries = 3,
$wait_seconds = 3);
$response = $client->Metrics->getMetrics();
try {
$client.Metrics.getMetrics();
} catch (Exception $e) {
if ($e->getCode() == SOME_INTEGER) {
doSomething();
}
}
## Positional Arguments
# $campaign_id | string
client->Campaigns->cancelCampaign($campaign_id);
## Positional Arguments
# $campaign_id | string
# $name | string
# $list_id | string
client->Campaigns->cloneCampaign($campaign_id, $name, $list_id);
## Positional Arguments
# $list_id | string
# $template_id | string
# $from_email | string
# $from_name | string
# $subject | string
## Keyword Arguments
# $name | string
# $use_smart_sending | bool
# $add_google_analytics | bool
client->Campaigns->createCampaign($list_id, $template_id, $from_email, $from_name, $subject);
## Positional Arguments
# $campaign_id | string
client->Campaigns->getCampaignInfo($campaign_id);
## Positional Arguments
# $campaign_id | string
## Keyword Arguments
# $count | int
# $sort | string
# $offset | string
client->Campaigns->getCampaignRecipients($campaign_id);
## Keyword Arguments
# $page | int
# $count | int
client->Campaigns->getCampaigns();
## Positional Arguments
# $campaign_id | string
# $send_time | string
client->Campaigns->scheduleCampaign($campaign_id, $send_time);
## Positional Arguments
# $campaign_id | string
client->Campaigns->sendCampaign($campaign_id);
## Positional Arguments
# $campaign_id | string
## Keyword Arguments
# $list_id | string
# $template_id | string
# $from_email | string
# $from_name | string
# $subject | string
# $name | string
# $use_smart_sending | bool
# $add_google_analytics | bool
client->Campaigns->updateCampaign($campaign_id);
## Keyword Arguments
# $body | array
client->DataPrivacy->requestDeletion();
## Positional Arguments
# $list_id | string
## Keyword Arguments
# $body | array
client->ListsSegments->addMembers($list_id);
## Positional Arguments
# $list_name | string
client->ListsSegments->createList($list_name);
## Positional Arguments
# $list_id | string
client->ListsSegments->deleteList($list_id);
## Positional Arguments
# $email | string
client->ListsSegments->excludeGlobally($email);
## Keyword Arguments
# $reason | string
# $sort | string
# $count | int
# $page | int
client->ListsSegments->getGlobalExclusions();
## Positional Arguments
# $list_id | string
## Keyword Arguments
# $marker | int
client->ListsSegments->getListExclusions($list_id);
## Positional Arguments
# $list_id | string
client->ListsSegments->getListInfo($list_id);
## Positional Arguments
# $list_id | string
## Keyword Arguments
# $body | array
client->ListsSegments->getListMembers($list_id);
## Positional Arguments
# $list_id | string
## Keyword Arguments
# $body | array
client->ListsSegments->getListSubscriptions($list_id);
client->ListsSegments->getLists();
## Positional Arguments
# $list_or_segment_id | string
## Keyword Arguments
# $marker | int
client->ListsSegments->getMembers($list_or_segment_id);
## Positional Arguments
# $segment_id | string
## Keyword Arguments
# $body | array
client->ListsSegments->getSegmentMembers($segment_id);
## Positional Arguments
# $list_id | string
## Keyword Arguments
# $body | array
client->ListsSegments->removeMembers($list_id);
## Positional Arguments
# $list_id | string
## Keyword Arguments
# $body | array
client->ListsSegments->subscribe($list_id);
## Positional Arguments
# $list_id | string
## Keyword Arguments
# $body | array
client->ListsSegments->unsubscribe($list_id);
## Positional Arguments
# $list_id | string
# $list_name | string
client->ListsSegments->updateListName($list_id, $list_name);
## Keyword Arguments
# $page | int
# $count | int
client->Metrics->getMetrics();
## Positional Arguments
# $metric_id | string
## Keyword Arguments
# $start_date | string
# $end_date | string
# $unit | string
# $measurement | string
# $where | string
# $by | string
# $count | int
client->Metrics->metricExport($metric_id);
## Positional Arguments
# $metric_id | string
## Keyword Arguments
# $since | string
# $count | int
# $sort | string
client->Metrics->metricTimeline($metric_id);
## Keyword Arguments
# $since | string
# $count | int
# $sort | string
client->Metrics->metricsTimeline();
## Keyword Arguments
# $body | array
client->Profiles->exchange();
## Positional Arguments
# $person_id | string
client->Profiles->getProfile($person_id);
## Keyword Arguments
# $email | string
# $phone_number | string
# $external_id | string
client->Profiles->getProfileId();
## Positional Arguments
# $person_id | string
# $metric_id | string
## Keyword Arguments
# $since | string
# $count | int
# $sort | string
client->Profiles->profileMetricTimeline($person_id, $metric_id);
## Positional Arguments
# $person_id | string
## Keyword Arguments
# $since | string
# $count | int
# $sort | string
client->Profiles->profileMetricsTimeline($person_id);
## Positional Arguments
# $person_id | string
## Keyword Arguments
# $params | array<string,mixed>
client->Profiles->updateProfile($person_id);
## Positional Arguments
# $template_id | string
# $name | string
client->Templates->cloneTemplate($template_id, $name);
## Positional Arguments
# $name | string
# $html | string
client->Templates->createTemplate($name, $html);
## Positional Arguments
# $template_id | string
client->Templates->deleteTemplate($template_id);
## Keyword Arguments
# $page | int
# $count | int
client->Templates->getTemplates();
## Positional Arguments
# $template_id | string
## Keyword Arguments
# $context | string
client->Templates->renderTemplate($template_id);
## Positional Arguments
# $template_id | string
# $from_email | string
# $from_name | string
# $subject | string
# $to | string
## Keyword Arguments
# $context | string
client->Templates->sendTemplate($template_id, $from_email, $from_name, $subject, $to);
## Positional Arguments
# $template_id | string
## Keyword Arguments
# $name | string
# $html | string
client->Templates->updateTemplate($template_id);
## Positional Arguments
# $data | string
client->TrackIdentify->identifyGet($data);
## Positional Arguments
# $data | string
client->TrackIdentify->identifyPost($data);
## Positional Arguments
# $data | string
client->TrackIdentify->trackGet($data);
## Positional Arguments
# $data | string
client->TrackIdentify->trackPost($data);