Skip to content

Export Users to Audience

Arcadier edited this page Sep 11, 2019 · 1 revision

Manually export Marketplace users to Mailchimp List / Audience.
     Screenshot-65

  1. Query for the current users in the marketplace
    $url = $baseUrl . '/api/v2/admins/'. $userId . '/users?role=user&ignoreGuest=true&pageSize=100';
    $result = callAPI("GET", $admin_token['access_token'], $url, false);
  2. Query for the each user's address
    $url = $baseUrl . '/api/v2/users/' . $userId .'/addresses';
    $useraddressinfo = callAPI("GET", $admin_token['access_token'], $url, false);
  3. Export each user to Audience.
    Screenshot-66

Batch Subscribe
function batchSubscribe(array $data, $apikey)
{
$auth = base64_encode('user:' . $apikey);
$json_postData = json_encode($data,true);
$ch = curl_init();
$dataCenter = substr($apikey, strpos($apikey, '-') + 1);
$curlopt_url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/batches/';
curl_setopt($ch, CURLOPT_URL, $curlopt_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic ' . $auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/3.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_postData);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return $result;
}

Clone this wiki locally