public function submit($values) { // try to submit, and save errors to be used when rendering fields again // save values $this->values = $values; // find email field $email = $this->getEmailField(); // try to submit to api $member = new Laposta_Member($this->list_id); $error = array(); try { $result = $member->create(array('ip' => $_SERVER['REMOTE_ADDR'], 'email' => $values[$email['field_id']], 'source_url' => $_SERVER['HTTP_REFERER'], 'custom_fields' => $this->getFieldsWithValues())); } catch (Exception $e) { $error = $e->json_body['error']; //print '<pre>';print_r($error);print '</pre>'; } // save error $this->error = $error; // return whether succeeded return $error ? false : true; }
<?php require_once '../../lib/Laposta.php'; Laposta::setApiKey("JdMtbsMq2jqJdQZD9AHC"); // initialize member with list_id $member = new Laposta_Member("BaImMu3JZA"); try { // update member, insert info as argument // $result will contain een array with the response from the server $result = $member->update('*****@*****.**', array('custom_fields' => array('name' => 'Maartje de Vries - Abbink', 'children' => 3, 'prefs' => array('optionC')))); print '<pre>'; print_r($result); print '</pre>'; } catch (Exception $e) { // you can use the information in $e to react to the exception print '<pre>'; print_r($e); print '</pre>'; }
<?php require_once '../../lib/Laposta.php'; Laposta::setApiKey("JdMtbsMq2jqJdQZD9AHC"); // initialize member with list_id $member = new Laposta_Member("BaImMu3JZA"); try { // get all members from this list // $result will contain een array with the response from the server $result = $member->all(); print '<pre>'; print_r($result); print '</pre>'; } catch (Exception $e) { // you can use the information in $e to react to the exception print '<pre>'; print_r($e); print '</pre>'; }
<?php require_once '../../lib/Laposta.php'; Laposta::setApiKey("JdMtbsMq2jqJdQZD9AHC"); // initialize member with list_id $member = new Laposta_Member("BaImMu3JZA"); try { // create new member, insert info as argument // $result will contain een array with the response from the server $result = $member->create(array('ip' => '198.51.100.0', 'email' => '*****@*****.**', 'source_url' => 'http://example.com', 'custom_fields' => array('name' => 'Maartje de Vries', 'dateofbirth' => '1973-05-10', 'children' => 2, 'prefs' => array('optionA', 'optionB')))); print '<pre>'; print_r($result); print '</pre>'; } catch (Exception $e) { // you can use the information in $e to react to the exception print '<pre>'; print_r($e); print '</pre>'; }
<?php require_once '../../lib/Laposta.php'; Laposta::setApiKey("JdMtbsMq2jqJdQZD9AHC"); //Laposta::setHttps(false); // initialize member with list_id $member = new Laposta_Member("BaImMu3JZA"); try { // get member info, use member_id or email as argument // $result will contain een array with the response from the server $result = $member->get("*****@*****.**"); print '<pre>'; print_r($result); print '</pre>'; } catch (Exception $e) { // you can use the information in $e to react to the exception print '<pre>'; print_r($e); print '</pre>'; }
<?php require_once '../../lib/Laposta.php'; Laposta::setApiKey("JdMtbsMq2jqJdQZD9AHC"); // initialize member with list_id $member = new Laposta_Member("BaImMu3JZA"); try { // (permanently) delete member, use member_id or email as argument // $result will contain een array with the response from the server $result = $member->delete("*****@*****.**"); print '<pre>'; print_r($result); print '</pre>'; } catch (Exception $e) { // you can use the information in $e to react to the exception print '<pre>'; print_r($e); print '</pre>'; }