【发布时间】:2017-05-18 20:01:07
【问题描述】:
我使用您的 PHP 包装器测试了 Mailchimp API v3。它对我很有用但是当我使用 POST 为“创建段”创建请求时出现错误(附上截图):
请求代码是(通过关联数组)-
$api_key = "xxxxxxxxxxxxxxxx-us11";
$list_id = "1xx2xx3xx4xx";
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->post('lists/' . $list_id . '/segments', array('name' => 'Testing Data',
'options' => array('match' => 'all',
'conditions' => array('field' => 'type', 'op' => 'is', 'value' => 'Testing'))
));
此请求调用返回以下错误 -
array (size=2) 'field' => string 'options.conditions' (length=18) 'message' => string 'Schema 描述了数组,而是找到了对象' (长度=44)
我也会尝试创建请求(通过关联数组)-
方法一:
$api_key = "xxxxxxxxxxxxxxxx-us11";
$list_id = "1xx2xx3xx4xx";
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->post('lists/' . $list_id . '/segments', array('name' => 'Testing Data',
'options' => array('match' => 'all',
'conditions' => array(array('field' => 'type', 'op' => 'is', 'value' => 'Testing')))
));
方法二:
$api_key = "xxxxxxxxxxxxxxxx-us11";
$list_id = "1xx2xx3xx4xx";
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->post('lists/' . $list_id . '/segments', array('name' => 'Testing Data 4',
'options' => array('match' => 'all',
'conditions' => array(array('field' => 'type'), array('op' => 'is'), array('value' => 'Testing')))
));
这两种方法都会在 mailchimp 帐户上创建段,但没有任何条件。看截图 -
如何解决这个问题?
【问题讨论】:
-
您可以尝试根据您的 Segemnet 类型命名您的 方法 1 中的最后一个数组,例如:
"conditions"=>array("EmailAddress"=>array("op"=>"foo", ... )),查看文档 -> developer.mailchimp.com/documentation/mailchimp/reference/lists/… . -
@Andy:谢谢,但这并没有解决我的问题。
-
好的,抱歉。愿你努力工作以达到预期的结果。尝试简单地将一个值放入数组,然后是另一个数组或对象,只是你想到的每个组合,并尝试在
conditions-Array 中获取内容