我嘗試過使用curl向MailChimp發送數據,但無法獲取要在MailChimp中保存的數據。任何幫助,將不勝感激!無法讓MailChimp API Curl正常工作
這裏是我的代碼:
$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);
什麼呢mailchimp回報呢? – 2014-08-29 02:46:50
它返回true – MagentoMan 2014-08-29 02:50:22
首先,我會建議您使用最新的2.0 API ...排序相同的結構,但它們簡化了一些事情。 – Oberst 2014-08-29 03:03:13