2009-08-11 98 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