POSTMAN ERROR!!!

laurentiu

Well-Known Member
Staff member Support Staff MailWizz 2.0 Tester
@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,

Screenshot 2021-04-20 at 10.09.28.png
 

Scott

Member
I've been searching literally all day for this solution. This should be in the API docs, would have saved me the past 6 hours of my time.

Where did you get the timestamp from @laurentiu ?

I copied yours exactly as in the photo and it worked for me, but I have no idea what it means.
 

laurentiu

Well-Known Member
Staff member Support Staff MailWizz 2.0 Tester
Is there any api to subscribers using csv file?
You can do this using custom code with $endpoint->createBulk(), bellow one example how you can do this:

PHP:
// 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);
}
 
Top