Using the CampaignMonitor API, I am able to subscribe, resubscribe and unsubscribe successfully, but I can't figure out how check if an email address is active, or unsubscribed. The end goal, is basically if subscribed, echo an unsubscribe link, if not subscribed echo a subscribe link.
After digging around CMBase it appears that subscribersGetIsSubscribed()
is what I need to target. I've successfully been able to tap into the function and get the proper true/false response when I echo $cm->debug_response. However, when I apply that into an if/else statement it doesn't work properly.
Example:
$result = $cm->subscribersGetIsSubscribed('[email protected]');
if ($cm->debug_response == "True") {
echo "active";
} else {
echo "not subscribed";
}
Someone in the CampaignMonitor forum answered, here is the result, which works properly...
$result = $cm->subscribersGetIsSubscribed('[email protected]',$list_id);
if ($result['anyType'] == "True") { echo "active"; } else { echo "not subscribed";}