Tôi đã thử và cố gắng gửi dữ liệu đến MailChimp bằng cách sử dụng curl nhưng không thể lấy dữ liệu để lưu trong MailChimp. Bất kỳ sự giúp đỡ này sẽ được đánh giá rất nhiều!Không thể nhận được API MailChimp Curl để làm việc
Đây là mã của tôi:
$mailChimpUrl = "http://us2.api.mailchimp.com/1.3/?method=listSubscribe";
$merges = array('FNAME'=>'Dave',
'LNAME'=>'Gilmour',
'BUILDING'=>'Central High School',
'MMERGE17' => '35904',
'MMERGE12'=>'Yes'
);
$apikey="myrealapiishere-us2";
$listId="myrealformidishere";
$email="[email protected]";
$double_optin=true;
$update_existing=false;
$replace_interests=true;
$send_welcome=false;
$email_type = 'html';
$data = array(
'email_address'=>$email,
'apikey'=>$apikey,
'merge_vars' => $merges,
'id' => $listId,
'double_optin' => $double_optin,
'update_existing' => $update_existing,
'replace_interests' => $replace_interests,
'send_welcome' => $send_welcome,
'email_type' => $email_type
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $mailChimpUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$result = curl_exec($ch);
curl_close($ch);
những gì hiện trở lại MailChimp? –
Nó trả về đúng – MagentoMan
Trước hết, tôi khuyên bạn nên sử dụng API 2.0 mới nhất ... Sắp xếp cùng một cấu trúc, nhưng chúng đơn giản hóa một vài điều. – Oberst