CampaignMonitor (PHP) 查找电子邮件是否被订阅
使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在尝试的 if/else 语句是什么? 根据文档,看起来应该可行:(
请注意,“True”是一个字符串文字,而不是像人们想象的那样,是真正的布尔值。)
What is the if/else statement you're attempting? Based on the documentation, it looks like this should work:
(Note that "True" is there a string literal, and not, as one would perhaps imagine, the true boolean value.)
CampaignMonitor 论坛中有人回答,这是结果,运行正常......
Someone in the CampaignMonitor forum answered, here is the result, which works properly...