You are here

function ConstantContact::add in Constant Contact 6

Same name and namespace in other branches
  1. 5 ConstantContact.php \ConstantContact::add()

Add a subscriber to your constant contact account, can be used to update their details too

* *

Parameters

string The email to subscribe: * @param array An array of extra fields to pass to CC, see docs for possible values * @return bool true on success false on failure

File

./ConstantContact.php, line 148

Class

ConstantContact
Class to interact with the constant contact API This class enables you to easily subscribe and unsubscribe members

Code

function add($email, $extra_fields = array()) {
  $email = urlencode(strip_tags($email));
  $data = 'loginName=' . $this
    ->getUsername();
  $data .= '&loginPassword=' . $this
    ->getPassword();
  $data .= '&ea=' . $email;
  $data .= '&ic=' . $this
    ->getCategory();
  if (is_array($extra_fields)) {
    foreach ($extra_fields as $k => $v) {
      $data .= "&" . urlencode(strip_tags($k)) . "=" . urlencode(strip_tags($v));
    }
  }
  return $this
    ->_send($data, $this->add_subscriber_url);
}