CampaignMonitor (PHP) 查找电子邮件是否被订阅

发布于 2024-07-30 17:25:54 字数 611 浏览 5 评论 0原文

使用 CampaignMonitor API,我能够成功订阅、重新订阅和取消订阅,但我不知道如何检查电子邮件地址是否处于活动状态或取消订阅。 最终目标基本上是,如果订阅,则回显取消订阅链接,如果未订阅,则回显订阅链接。

在深入了解 CMBase 后,似乎 subscribersGetIsSubscribed() 就是我需要定位的目标。 当我回显 $cm->debug_response 时,我已经成功地利用了该函数并获得了正确的真/假响应。 但是,当我将其应用于 if/else 语句时,它无法正常工作。

例子:

$result = $cm->subscribersGetIsSubscribed('[email protected]');
if ($cm->debug_response == "True") { 
    echo "active"; 
} else { 
    echo "not subscribed";
}

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";
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浪荡不羁 2024-08-06 17:25:54

您正在尝试的 if/else 语句是什么? 根据文档,看起来应该可行:(

$result = $cm->subscribersGetIsSubscribed('[email protected]');
if ($result == 'True') {
    echo 'active';
} else {
    echo 'not subscribed';
}

请注意,“True”是一个字符串文字,而不是像人们想象的那样,是真正的布尔值。)

What is the if/else statement you're attempting? Based on the documentation, it looks like this should work:

$result = $cm->subscribersGetIsSubscribed('[email protected]');
if ($result == 'True') {
    echo 'active';
} else {
    echo 'not subscribed';
}

(Note that "True" is there a string literal, and not, as one would perhaps imagine, the true boolean value.)

不语却知心 2024-08-06 17:25:54

CampaignMonitor 论坛中有人回答,这是结果,运行正常......

$result = $cm->subscribersGetIsSubscribed('[email protected]',$list_id);

if ($result['anyType'] == "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";}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文