<?php /** * This file contains examples for using the EmailOneApi PHP-SDK. * * * * */ // require the setup which has registered the autoloader require_once dirname(__FILE__) . '/setup.php'; // CREATE THE ENDPOINT $endpoint = new EmailOneApi_Endpoint_ListSubscribers(); /*===================================================================================*/ // GET ALL ITEMS $response = $endpoint->getSubscribers('LIST-UNIQUE-ID', $pageNumber = 1, $perPage = 10); // DISPLAY RESPONSE echo '<pre>'; print_r($response->body); echo '</pre>'; /*===================================================================================*/ // GET ONE ITEM $response = $endpoint->getSubscriber('LIST-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID'); // DISPLAY RESPONSE echo '<hr /><pre>'; print_r($response->body); echo '</pre>'; /*===================================================================================*/ // SEARCH BY EMAIL $response = $endpoint->emailSearch('LIST-UNIQUE-ID', '*****@*****.**'); // DISPLAY RESPONSE
/** * This file contains examples for using the EmailOneApi PHP-SDK. * * * * */ // require the setup which has registered the autoloader require_once dirname(__FILE__) . '/setup.php'; // see if the request is made via ajax. $isAjaxRequest = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; // and if it is and we have post values, then we can proceed in sending the subscriber. if ($isAjaxRequest && !empty($_POST)) { $listUid = 'ah2849chx4451'; // you'll take this from your customers area, in list overview from the address bar. $endpoint = new EmailOneApi_Endpoint_ListSubscribers(); $response = $endpoint->create($listUid, array('EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : null, 'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : null, 'LNAME' => isset($_POST['LNAME']) ? $_POST['LNAME'] : null)); $response = $response->body; // if the returned status is success, we are done. if ($response->itemAt('status') == 'success') { exit(EmailOneApi_Json::encode(array('status' => 'success', 'message' => 'Thank you for joining our email list. Please confirm your email address now!'))); } // otherwise, the status is error exit(EmailOneApi_Json::encode(array('status' => 'error', 'message' => $response->itemAt('error')))); } ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="content-type" content="text/html" /> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans" />