0
試圖更新一批電子郵件。我想我已經想盡辦法做到這一點,但我使用的DrewM's MailChimp wrapper只返回以下$result
內容:MailChimp API 3.0批量更新 - 始終處於待處理狀態,total_operations:0
Array ([id] => 1234abcd [status] => pending [total_operations] => 0 [finished_operations] => 0
等。沒有錯誤,但沒有操作!
本質上,我的代碼如下所示,其中$emails
將所有電子郵件存儲在一個數組中。
include("MailChimp.php");
include("Batch.php");
$list_id = "1234abcd";
use \DrewM\MailChimp\MailChimp;
use \DrewM\MailChimp\Batch;
$apiKey = 'aslkjf84983hg84938h89gd-us13';
if(!isset($emails)){ // If not sending bulk requests
$MailChimp = new MailChimp($apiKey);
$subscriber_hash = $MailChimp->subscriberHash($email);
$result = $MailChimp->patch("lists/$list_id/members/$subscriber_hash",
array(
'status' => 'subscribed',
)
);
/* SENDING BATCH OF EMAILS */
} else if($emails){
$MailChimp = new MailChimp($apiKey);
$Batch = $MailChimp->new_batch();
$i = 1;
foreach($emails as &$value){
$Batch->post("op".$i, "lists/$list_id/members", [
'email_address' => $value,
'status' => 'subscribed',
]);
$i++;
}
$result = $Batch->execute(); // Send the request (not working I guess)
$MailChimp->new_batch($batch_id); // Now get results
$result = $Batch->check_status();
print_r($result);
}
如果有人能看到我沒有看到的東西,我將非常感激!