Created
May 6, 2011 20:19
-
-
Save carcus88/959709 to your computer and use it in GitHub Desktop.
OemPro API - Subscriber.Get
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Check for required fields - Start | |
$ArrayRequiredFields = array('emailaddress' => 1, 'listid' => 2); | |
$ArrayErrorFields = FormHandler::RequiredFieldValidator($ArrayAPIData, $ArrayRequiredFields); | |
if (count($ArrayErrorFields) > 0) | |
{ | |
$ArrayOutput = array('Success' => false, | |
'ErrorCode' => $ArrayErrorFields, | |
); | |
throw new Exception(''); | |
} | |
// Check for required fields - End | |
// Field validations - Start | |
// There's no field valdiation for this functionality | |
// Field validations - End | |
// Load other modules - Start | |
Core::LoadObject('users'); | |
Core::LoadObject('lists'); | |
// Load other modules - End | |
// Get subscriber - Start | |
if (!empty($ArrayAPIData['suppressed'])) { | |
Core::LoadObject('suppression_list'); | |
$SupressedSubscribers = SuppressionList::GetEmailAddresses(array('*'), array('RelOwnerUserID' => $ArrayUserInformation['UserID'], 'RelListID' => 0, 'EmailAddress' => $ArrayAPIData['emailaddress'])); | |
if ( ! empty($SupressedSubscribers)) { | |
$Subscriber = $SupressedSubscribers[0]; | |
} | |
} else { | |
Core::LoadObject('subscribers'); | |
$Subscriber = Subscribers::RetrieveSubscriber(array('*'), array('EmailAddress' => $ArrayAPIData['emailaddress']), $ArrayAPIData['listid']); | |
} | |
if (! $Subscriber) | |
{ | |
$ArrayOutput = array('Success' => false, | |
'ErrorCode' => array(3), | |
); | |
throw new Exception(''); | |
} | |
// Get subscriber - End | |
// Return results - Start | |
$ArrayOutput = array('Success' => true, | |
'ErrorCode' => 0, | |
'SubscriberInformation' => $Subscriber | |
); | |
// Return results - End | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: includes/api/subscriber.get.inc.php | |
=================================================================== | |
--- includes/api/subscriber.get.inc.php (revision 142713) | |
+++ includes/api/subscriber.get.inc.php (working copy) | |
@@ -17,12 +17,20 @@ | |
// Load other modules - Start | |
Core::LoadObject('users'); | |
-Core::LoadObject('subscribers'); | |
Core::LoadObject('lists'); | |
// Load other modules - End | |
// Get subscriber - Start | |
-$Subscriber = Subscribers::RetrieveSubscriber(array('*'), array('EmailAddress' => $ArrayAPIData['emailaddress']), $ArrayAPIData['listid']); | |
+if (!empty($ArrayAPIData['suppressed'])) { | |
+ Core::LoadObject('suppression_list'); | |
+ $SupressedSubscribers = SuppressionList::GetEmailAddresses(array('*'), array('RelOwnerUserID' => $ArrayUserInformation['UserID'], 'RelListID' => 0, 'EmailAddress' => $ArrayAPIData['emailaddress'])); | |
+ if ( ! empty($SupressedSubscribers)) { | |
+ $Subscriber = $SupressedSubscribers[0]; | |
+ } | |
+} else { | |
+ Core::LoadObject('subscribers'); | |
+ $Subscriber = Subscribers::RetrieveSubscriber(array('*'), array('EmailAddress' => $ArrayAPIData['emailaddress']), $ArrayAPIData['listid']); | |
+} | |
if (! $Subscriber) | |
{ | |
$ArrayOutput = array('Success' => false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Check for required fields - Start | |
$ArrayRequiredFields = array( | |
'subscribers' => 1, | |
'subscriberlistid' => 2 | |
); | |
$ArrayErrorFields = FormHandler::RequiredFieldValidator($ArrayAPIData, $ArrayRequiredFields); | |
if (count($ArrayErrorFields) > 0) | |
{ | |
$ArrayOutput = array('Success' => false, | |
'ErrorCode' => $ArrayErrorFields, | |
'ErrorText' => array('Subscriber ID numbers are missing'), | |
); | |
throw new Exception(''); | |
} | |
// Check for required fields - End | |
// Field validations - Start | |
// There's no field valdiation for this functionality | |
// Field validations - End | |
// Load other modules - Start | |
Core::LoadObject('subscribers'); | |
// Load other modules - End | |
// Delete subscribers - Start | |
if (isset($ArrayAPIData['suppressed']) && $ArrayAPIData['suppressed']) | |
{ | |
Subscribers::RemoveSuppressedSubscribersByIDFromSuppressionList($ArrayAPIData['subscriberlistid'], explode(',', $ArrayAPIData['subscribers'])); | |
} | |
else | |
{ | |
Subscribers::RemoveSubscribersByID($ArrayAPIData['subscriberlistid'], explode(',', $ArrayAPIData['subscribers'])); | |
} | |
// Delete subscribers - End | |
// Return results - Start | |
$ArrayOutput = array('Success' => true, | |
'ErrorCode' => 0, | |
'ErrorText' => '' | |
); | |
// Return results - End | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: includes/api/subscribers.delete.inc.php | |
=================================================================== | |
--- includes/api/subscribers.delete.inc.php (revision 142713) | |
+++ includes/api/subscribers.delete.inc.php (working copy) | |
@@ -24,7 +24,7 @@ | |
Core::LoadObject('subscribers'); | |
// Load other modules - End | |
-// Delete auto responders - Start | |
+// Delete subscribers - Start | |
if (isset($ArrayAPIData['suppressed']) && $ArrayAPIData['suppressed']) | |
{ | |
Subscribers::RemoveSuppressedSubscribersByIDFromSuppressionList($ArrayAPIData['subscriberlistid'], explode(',', $ArrayAPIData['subscribers'])); | |
@@ -33,7 +33,7 @@ | |
{ | |
Subscribers::RemoveSubscribersByID($ArrayAPIData['subscriberlistid'], explode(',', $ArrayAPIData['subscribers'])); | |
} | |
-// Delete auto responders - End | |
+// Delete subscribers - End | |
// Return results - Start | |
$ArrayOutput = array('Success' => true, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently when you have a global suppression list you can use the Subscribers.delete function to remove an email from it but you need to get the ID first. To do this I modified Subscriber.get to be able to find an entry in the suppression list by passing the "suppressed" option. This way you can use the API to find the email in the suppression list, get the ID and them remove the email from the suppression list.