我正在尝试使用curl从mailchimp中获取列表成员。
这是我的代码。
我无法确定api密钥的放置位置。
这是我现在拥有的代码:
$apiKey = 'xxxxxxxxxxxxxxxxxx';
$list_id = 'aaaaaaaaaa';
$dataCenter = substr($apiKey,strpos($apiKey,'-')+1);
$url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/'.$list_id;
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));
$result = curl_exec($cURL);
curl_close($cURL);
echo '<pre>';
var_dump($result);
echo '</pre>';
答案 0 :(得分:0)
据我所读的mailchimp documents,也许您需要添加CURLOPT_USERPWD
选项。
curl_setopt($cURL, CURLOPT_USERPWD, $username . ':' . $apiKey);
请将您的mailchimp用户名设置为$username
。