3

任何人都知道如何让一个活动发送到一个细分市场?此代码不起作用。它将向竞选活动中的所有人发送一封电子邮件。它不会使用该段。(这是更多的文本,所以我可以让它通过 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);
4

1 回答 1

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 完成的。

于 2012-10-25T17:31:08.713 回答