2016-03-03 30 views
3

使用MailChimp API V3.0創建廣告系列。使用MailChimp API V3.0創建包含動態細分的廣告系列

我想創建一個廣告系列,發送給有特定興趣的用戶。看起來這在文檔中是可行的,但我已經嘗試了所有我能想到的排列方式。只要我省略segment_ops成員,我就可以創建此廣告系列。有沒有人有這樣做的PHP代碼的例子?

似乎感興趣的處理方式很奇怪,因爲您在通過API設置用戶興趣時不包括興趣類別。我不確定這會如何影響廣告系列的製作。

+0

好像您MailChimp代表 –

+0

一個問題這是一個免費的MailChimp帳戶以非常低的量,所以沒有支持。我在這裏發現了一些關於MC API的其他有用答案,所以希望有人這樣做會發佈一個工作示例。 –

回答

11

我已經得到了這個工作,雖然沒有辦法從當前的文檔中獲得它,它沒有列出'興趣'condition_type或可能的'op'值。

興趣必須歸入興趣類別(在用戶界面的某些部分稱爲「組」)。

下面是收件人陣列的segment_opts成員JSON:

"segment_opts": { 
     "match": "any", 
     "conditions": [{ 
      "condition_type": "Interests", 
      "field": "interests-31f7aec0ec", 
      "op": "interestcontains", 
      "value": ["a9014571b8", "5e824ac953"] 
     }] 
} 

這裏是PHP陣列版本註釋。 「匹配」成員引用「條件」數組中的規則。細分受衆羣可以匹配任何條件,全部條件或全部條件。此示例只有一個條件,但可以將其他數組作爲「條件」數組中的附加數組添加:

$segment_opts = array(
'match' => 'any', // or 'all' or 'none' 
'conditions' => array (
    array(
     'condition_type' => 'Interests', // note capital I 
     'field' => 'interests-31f7aec0ec', // ID of interest category 
              // This ID is tricky: it is 
              // the string "interests-" + 
              // the ID of interest category 
              // that you get from MailChimp 
              // API (31f7aec0ec) 
     'op' => 'interestcontains', // or interestcontainsall, interestcontainsnone 
     'value' => array (
      'a9014571b8', // ID of interest in that category 
      '5e824ac953' // ID of another interest in that category 
     ) 
    ) 

) 
); 
+0

so interested-31f7aec0ec是類別的id。那麼這個條件是否與那些有興趣的用戶匹配?你能詳細說明interestcontains的含義嗎? ---最終,我只想給所有對interest_id「X」感興趣的用戶發送一封電子郵件(我不太在意類別) – maxfowler

+0

interestcontains只是告訴MG選擇用戶感興趣的用戶, 'value'數組中包含的ID –

0

您也可以發送到已保存的段。這個問題是segment_id必須是int。我將這個值作爲varchar保存在db中,除非強制轉換爲int,否則它將不起作用。

(我用使用\ DrewM \ MailChimp \ MailChimp;)

$segment_id = (int) $methodThatGetsMySegmentID; 

$campaign = $MailChimp->post("campaigns", [ 
    'type' => 'regular', 
    'recipients' => array(
     'list_id' => 'abc123yourListID', 
     'segment_opts' => array(
      'saved_segment_id' => $segment_id, 
     ), 
    ), 
    'settings' => array(
     'subject_line' => 'A New Article was Posted', 
     'from_name' => 'From Name', 
     'reply_to' => '[email protected]', 
     'title' => 'New Article Notification' 
    ) 
]); 
相關問題