This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Setup

Setup endpoints of the MailWizz API.

    Please make sure to replace API-URL PUBLIC-KEY, with their proper values:

    //Require the autoloader class if you haven't used composer to install the package
    require_once __DIR__ . '/../vendor/autoload.php';
    
    //Configuration object (Get your API info from: https://kb.mailwizz.com/articles/find-api-info/) :
    $config = new \EmsApi\Config([
        'apiUrl'    => 'API-URL',
        'apiKey'    => 'PUBLIC-KEY',
    
        // components
        'components' => [
            'cache' => [
                'class'     => \EmsApi\Cache\File::class,
                'filesPath' => __DIR__ . '/data/cache', // make sure it is writable by webserver
            ]
        ],
    ]);
    //Now inject the configuration and we are ready to make api calls
    \EmsApi\Base::setConfig($config);
    
    //Start UTC
    date_default_timezone_set('UTC');
    require '../mailwizz/mailwizz'
    
    include Mailwizz
    include Endpoint
    
    # noinspection SpellCheckingInspection
    config = Config.new({
                            'api_url': 'API-URL',
                            'public_key': 'PUBLIC-KEY',
                            'charset': 'utf-8'
                        })
    
    # now inject the configuration and we are ready to make api calls
    Base.config = config
    from mailwizz.base import Base
    from mailwizz.config import Config
    
    def setup():
      
        # configuration object
        config = Config({
            'api_url': 'API-URL',
            'public_key': 'PUBLIC-KEY',
            'charset': 'utf-8'
        })
    
        # now inject the configuration and we are ready to make api calls
        Base.set_config(config)

    See each language tab for the setup instructions.

    Notes