Thank you so much. Can you show me a sample printout for the example of adding new subscribers?@barisb - I tested and it's working correctly.
To be able to use in postman you have to manually enter special headers such as:
'X-MW-PUBLIC-KEY' => publicKey,
'X-MW-TIMESTAMP' => timestamp,
View attachment 13177
Where did you get the timestamp from @laurentiu ?
Hi is there a limit of how many subscribers I can post in bulk with one API call? For some reason it is only postting 332 subscribers?
You can do this using custom code with $endpoint->createBulk(), bellow one example how you can do this:Is there any api to subscribers using csv file?
// Array with all subscribers data
$subscribers = [];
// file name, where __DIR__ = represents the directory of the current file
$file = __DIR__ . '/your_list_name.csv';
// Count how may subscribers are in array
// We want to add 100 subscribers per batch
$counter = 0;
if (($handle = fopen($file, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
for ($c=0; $c < $num; $c++) {
$email = $data[$c];
$subscriber = [
'EMAIL' => $email,
];
array_push($subscribers, $subscriber);
// We want to add only 100 subscribers per batch
if ($counter >= 100) {
$response = $endpoint->createBulk('sy349pvrhha89', $subscribers);
// Print response status
echo $response->body['status'] . PHP_EOL;
// empty the array to have a new 100 subscribers
$subscribers = [];
// Reset counter
$counter = 0;
}
$counter++;
}
}
fclose($handle);
}
Is there any api to create subscribers using csv file?
Or you can use the queue importer, you have plenty options.ou can do this using custom code with $endpoint->createBulk(),
I tried using api to send transactional mails with this php codeOr you can use the queue importer, you have plenty options.
<?php
$data = [
'to_name' => 'John Doe', // required
'to_email' => 'remzino1@gmail.com', // required
'from_name' => 'Jane Doe', // required
'subject' => 'This is the email subject', // required
'body' => '<strong>Hello world!</strong>', // required
'send_at' => date('Y-m-d H:i:s'),
];
$url = 'https://[mailwizz-api-url]/api/transactional-emails';
$apiKey = 'api-key';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_HTTPHEADER => array(
'X-Api-Key: ' . $apiKey,
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
{"status":"error","error":"To email cannot be blank.<br \/>To name cannot be blank.<br \/>From name cannot be blank.<br \/>Subject cannot be blank.<br \/>Body cannot be blank."}