Exemplo n.º 1
0
 /**
  * Search for contacts in a list who have been updated since a given date
  * @param ContactList $List - ContactList object to search
  * @param  string $date - Last updated date to search from
  * @return array - Up to 50 contacts and a link to the next page if one exists
  */
 public function searchContactsByLastUpdate(ContactList $List, $date){
     $ContactsCollection = new ContactsCollection($this->CTCTRequest);
     return $ContactsCollection->searchContactsByLastUpdate($List, $date);
 }
Exemplo n.º 2
0
 function signup_user_constant_contact($firstname, $lastname, $email, $list)
 {
     global $premise_base;
     require_once PREMISE_LIB_DIR . 'constant_contact_api/constant_contact_api.php';
     $settings = $premise_base->get_settings();
     $optin = $settings['optin'];
     $premise_base->setup_constant_contact($this->_optin_ConstantContactKey, $optin['constant-contact-username'], $optin['constant-contact-password']);
     $collection = new ContactsCollection();
     list($search) = $collection->searchByEmail($email);
     if (!empty($search)) {
         foreach ($search as $possible) {
             if ($email == $possible->getEmailAddress()) {
                 $contact = $collection->getContact($possible->getLink());
                 break;
             }
         }
     }
     $listKey = 'http://api.constantcontact.com/ws/customers/' . $optin['constant-contact-username'] . '/lists/' . $list;
     if ($contact) {
         $existingLists = $contact->getLists();
         if (in_array($listKey, $existingLists)) {
             return array('error' => __('You have already subscribed to this mailing list', 'premise'));
         } else {
             $contact->setLists($listKey);
         }
         $contact->setFirstName($firstname);
         $contact->setLastName($lastname);
         $result = $collection->updateContact($contact->getId(), $contact);
     } else {
         $contact = new Contact();
         $contact->setFirstName($firstname);
         $contact->setLastName($lastname);
         $contact->setEmailAddress($email);
         $contact->setLists($listKey);
         $result = $collection->createContact($contact);
     }
     $first = substr((string) $result, 0, 1);
     if ($first != 2) {
         return array('error' => __('Could not subscribe you to this mailing list', 'premise'));
     }
     return true;
 }