如何在Campaign Monitor中获取Segment API ID?

时间:2014-11-12 00:43:04

标签: api campaign-monitor

我正在创建一个PHP工具,可以使用API​​通过Campaign Monitor自动发送电子邮件广告系列。我可以很容易地获得列表的ID但不是段。那么,我如何获得细分的ID?

' ListIDs' =>数组(' ID在这里')

1 个答案:

答案 0 :(得分:1)

这个脚本解决了我的问题。

//List all Segment with its Segment IDs
/*
$apikey = 'YOUR API KEY';
$listid = 'YOUR LIST ID';

$segments_wrap = new CS_REST_Lists($listid, $apikey);
$segments_result = $segments_wrap->get_segments();

if($segments_result->was_successful()) {
    echo "<ul>\n";
    foreach ($segments_result->response as $segment) {
        $segment_details_wrap = new CS_REST_Segments($segment->SegmentID, $apikey);
        $segment_details_result = $segment_details_wrap->get();

        if($segment_details_result->was_successful()) {
            echo "<li>";
            echo $segment_details_result->response->Title;
            echo ": ";
            echo $segment_details_result->response->ActiveSubscribers;
            echo "</li>\n";
            echo $segment_details_result->response->SegmentID;
            echo "</li>\n";
        }
    }
    echo "</ul>\n";
}*/