I am creating a PHP tools which can auto send email campaign via Campaign Monitor using API. I could easily get the ID of a list but not segment. So, how can I get the ID of a segment?
'ListIDs' => array('ID goes here')
This script solved my problem.
//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";
}*/