<?php require 'Mailin.php'; /* * This will initiate the API with the endpoint and your access key. * */ $mailin = new Mailin('https://api.sendinblue.com/v2.0', 'Your access key'); /* * This will get all your campaigns * */ var_dump($mailin->get_campaigns_v2());
/** * get template lists of sendinblue */ public static function get_template_lists() { $mailin = new Mailin(SIB_Manager::sendinblue_api_url, SIB_Manager::$access_key); $data = array('type' => 'template', 'status' => 'temp_active'); $response = $mailin->get_campaigns_v2($data); if (!isset($response['code']) || $response['code'] != 'success') { return null; } return $response['data']['campaign_records']; }
/** * Get campaign stats */ static function get_campaign_stats() { $access_key = SIB_Manager::$access_key; $mailin = new Mailin(SIB_Manager::sendinblue_api_url, $access_key); $data = array(); $response = $mailin->get_campaigns_v2($data); $ret = array('classic' => array('Sent' => 0, 'Draft' => 0, 'Queued' => 0, 'Suspended' => 0, 'In_process' => 0, 'Archive' => 0, 'Sent and Archived' => 0, 'Temp_active' => 0, 'Temp_inactive' => 0, 'Scheduled' => 0), 'sms' => array('Sent' => 0, 'Draft' => 0, 'Queued' => 0, 'Suspended' => 0, 'In_process' => 0, 'Archive' => 0, 'Sent and Archived' => 0, 'Temp_active' => 0, 'Temp_inactive' => 0, 'Scheduled' => 0), 'trigger' => array('Sent' => 0, 'Draft' => 0, 'Queued' => 0, 'Suspended' => 0, 'In_process' => 0, 'Archive' => 0, 'Sent and Archived' => 0, 'Temp_active' => 0, 'Temp_inactive' => 0, 'Scheduled' => 0)); $campaign_records = $response['data']['campaign_records']; if (isset($campaign_records) && is_array($campaign_records)) { foreach ($campaign_records as $campaign_record) { if ($campaign_record['type'] == 'template' || $campaign_record['type'] == '') { continue; } $ret[$campaign_record['type']][$campaign_record['status']]++; } } return $ret; }
<?php require 'Mailin.php'; /* * This will initiate the API with the endpoint and your access key. * */ $mailin = new Mailin('https://api.sendinblue.com/v2.0', 'Your access key'); /* * This will get all your campaigns * */ /** Prepare variables for easy use **/ $data = array("type" => "classic", "status" => "queued", "page" => 1, "page_limit" => 10); var_dump($mailin->get_campaigns_v2($data));