Subscription and unsubscription API
This API will allow you to direct subscribe, unsubscribe or get a subscriptor status
The request method can be POST or GET
Examples of usage:
The request method can be POST or GET
Examples of usage:
http://mailingdomain.com/api.php?apikey=db2542df8c4b08d&action=subscribe&email=user@domain.com&name=John http://mailingdomain.com/api.php?apikey=db2544df8c4b08d&action=unsubscribe&email=user@domain.com http://domain.com/api.php?apikey=db2542df8c4b08d&action=subscribe&email=user@domain.com&unsus_date=1320422607
Parameters:
| apikey | The API Key for the specified list |
|---|---|
| action | subscribe or unsubscribe or status |
| Email to subscribe, unsubscribe or get status | |
| name | Optional value, only for subscription |
| unsus_date | Optional value, only for subscription. Subscription term in UNIX format (example: 1317830607) |
| success_url | The URL to redirect if success |
| error_url | The URL to redirect on error. Variables "error" and "errno" are passed as GET method |
Return values:
| status | "Email added" in case of a successful subscription |
|---|---|
| status | "Email unsubscribed" in case of a successful unsubscription |
| For a status request: | |
| Subscriber email | |
| name | Subscriber name |
| creation_date | Subscriber creation date in UNIX format |
| unsus_date | Subscriber unsubscription term date in UNIX format |
| active | Subscriber status, 1=active, 0=inactive (will not receive emails in inactive status) |
Error codes:
| 1101 | "Invalid list or api key" |
|---|---|
| 1102 | "Action not recognized" invalid action name |
| 1103 | "Invalid emails address" |
| 1104 | "Subscribers quota exceeded" maybe the list is full or you have reached you subscribers limit |
| 1105 | "Email already exist in this list" while trying to subscribe an email |
| 1106 | "Unsubscription date is in the past" while trying to subscribe an email |
| 1107 | "Email not in list" while trying to unsubscribe an email |
| 1107 | The email address entered is blacklisted. It must be subscribed by an double opt-in form |
PHP Example script:
<?phpÂ
$apykey = "34f89h3498fu" ;
$email = "john@mydomain.com" ;
$url = "http://www.youmailing.com/app/" ;
$query_string = $url . "api.php?apikey=" . $apikey . "&action=subscribe&email=" . $email ;
$response = file_get_contents ( $query_string );Â
$dataArray = json_decode ( $response );
if ( $dataArray [ "error" ] )Â
{
// An error occur, do something with $dataArray["message"]
} else {
// It is ok, you got the status on $dataArray["status"]
}
?>