duanpin2009 2018-03-23 13:44
浏览 37
已采纳

Mailchimp API v3.0将订阅者添加到段,而不是在管理员中显示

I am trying to add a user that is in the list to a segment using drewm's Mailchimp php API wrapper

Creating the segment if it doesn't exist works fine, and it displays in the MailChimp environment. If I then try to add a subscriber using POST /lists/{list_id}/segments/{segment_id}, the API responds like it should, stating that the subscriber has been added to the segment, or telling me the subscriber hasn't been added if the subscriber is already in the segment. But in the MailChimp admin, the segment still displays as empty. Here is my code, I have no idea where I'm going wrong:

// Segmentation
// Check if event has segment linked, if not, create segment and add to post meta
$event_segment = get_post_meta($event->post_id, 'byron_mailchimp_segment', true);

if (empty($event_segment)) {
    // Create new segment,
    $create_segment_response = $MailChimp->post('/lists/' . $event_list . '/segments/', [
        'name' => 'Aangemeld',
        'static_segment' => [],
    ]);

    $event_segment = $create_segment_response['id'];
    // Save segment ID to post meta
    add_post_meta($event->post_id, 'byron_mailchimp_segment', $event_segment);
}

$add_to_segment_response = $MailChimp->post('/lists/' . $event_list . '/segments/' . $event_segment, [
    'members_to_add' => [$member['user_email']],
]);

echo "<pre>";
var_dump($add_to_segment_response);
echo "</pre>";

I've already checked if the $event_segment contains the right ID, and it does.

  • 写回答

1条回答 默认 最新

  • dousong2967 2018-03-25 23:31
    关注

    It's probable that this is a caching issue!

    I've experienced something like this before, and it always shows up up a few minutes to an hour later.

    Two suggestions to help diagnose:

    1. Try the API playground for extra confirmation that it's indeed there, while you wait!
    2. You may also be able to look "around" the problem by searching up the user's email and seeing if the segment's reflected on their individual entry. That wouldn't likely be cached.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答