2009-08-11 103 views
0

使用CampaignMonitor API,我可以成功订阅,重新订阅和取消订阅,但我无法弄清楚如何检查电子邮件地址是活动还是取消订阅。最终目标,基本上是如果订阅,回显一个退订链接,如果没有订阅回应一个订阅链接。CampaignMonitor(PHP)查找订阅电子邮件

挖掘CMBase后,看起来subscribersGetIsSubscribed()是我需要的目标。当我回显$ cm-> debug_response时,我已经成功地使用该函数并获得正确的真/假响应。但是,当我将它应用于if/else语句时,它无法正常工作。

例子:

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

回答

0

有人在CampaignMonitor论坛上回答,这里是结果,它能正常工作...

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

if ($result['anyType'] == "True") { echo "active"; } else { echo "not subscribed";} 
0

什么是if/else语句你尝试?基于文档,它看起来像这应该工作:

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

(请注意,“真”是有一个字符串,而不是作为一个或许会想象,真正的布尔值。)

+0

感谢您的回答。返回的结果是一个数组,而不是一个字符串。我发现保存该值的数组键是'anyType'。再次感谢您的努力:) – 2009-08-11 16:18:53