将广告系列发送到细分受众群

时间:2012-10-01 19:12:39

标签: mailchimp

任何人都知道如何将广告系列发送到某个细分受众群?此代码无效。它会向广告系列中的所有人发送电子邮件。它不会使用该细分。 (这是一些更多的文本,所以我可以让它通过SO的验证。)

我的代码:

    //get member list
    $memberArray = $api->listMembers($inStockListId);
    foreach ($memberArray['data'] as $member) {
        $memberInfo = $api->listMemberInfo($inStockListId, $member['email']);
        $_productId = $memberInfo['data'][0]['merges']['PRODUCTID'];

$productId='34';
        if ($productId == $_productId) {
            array_push($emailArray, $member['email']);
        }
    }

    //create new segment for campaign
    $listStaticSegmentId = $api->listStaticSegmentAdd($inStockListId, 'inStockStaticSegment');

    //add members to segment
    $val = $api->listStaticSegmentMembersAdd($inStockListId, $listStaticSegmentId, $emailArray);

    $conditions = array();
    $conditions[] = array(
        'field' => 'email',
        'op'    => 'like',
        'value' => '%'
    );
    $segment_options = array(
        'match'      => 'all',
        'conditions' => $conditions
    );

    $type    = 'regular';
    $options = array(
        'template_id' => $campaignTemplateId,
        'list_id'     => $inStockListId,
        'subject'     => 'In-Stock Notification',
        'from_email'  => 'from@email.com',
        'from_name'   => 'My From Name'
    );
    $content = array(
        'html_main'       => 'some pretty html content',
        'html_sidecolumn' => 'this goes in a side column',
        'html_header'     => 'this gets placed in the header',
        'html_footer'     => 'the footer with an *|UNSUB|* message',
        'text'            => 'text content text content *|UNSUB|*'
    );

    $newCampaignId = $api->campaignCreate($type, $options, $content, $segment_options);

1 个答案:

答案 0 :(得分:2)

我明白了。基本上,这是流程。如果您需要详细的代码,请给我发消息,我很乐意为您提供帮助。

$api = new MCAPI($this->_apiKey);
$api->listMemberInfo($this->_listId, $member['email']);
$api->listUpdateMember($this->_listId, $member['email'], $mergeVars);
$api->listStaticSegmentDel($this->_listId, $segment['id']);
$api->listStaticSegmentAdd($this->_listId, $segmentName);
$api->listStaticSegmentMembersAdd($this->_listId, $segmentId, $emailArray);
$api->campaignCreate($type, $options, $content, $segment_options);
//$api->campaignSendTest($newCampaignId, array($member['email']));
$api->campaignSendNow($newCampaignId);

请注意,这是通过MailChimp PHP API完成的。