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" /> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Noto+Sans:700italic" /> <link rel="stylesheet" type="text/css" href="http://www.emailone.net/api/assets/css/bootstrap.css" /> <link rel="stylesheet" type="text/css" href="http://www.emailone.net/api/assets/css/bootstrap-glyphicons.css" /> <link rel="stylesheet" type="text/css" href="http://www.emailone.net/api/assets/css/style.css" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript" src="http://www.emailone.net/api/assets/js/bootstrap.js" id="script-bootstrap"></script> <link rel="shortcut icon" href="http://www.emailone.net/favicon.ico" type="image/x-icon" /> <title>Ajax subscribe</title>