Mailwizz API

majid1f

Active Member
MailWizz 2.0 Tester
Hi, I'm using mailiwzz api for creating campaign in my CRM. I Could make campaign , but i need to pause or check as draft campaign immediately after create campaing. I used this method:
Code:
// CREATE THE ENDPOINT
$endpoint = new MailWizzApi_Endpoint_Campaigns();
// Pause/Unpause CAMPAIGN
$response = $endpoint->pauseUnpause('CAMPAIGN-UNIQUE-ID');
// DISPLAY RESPONSE
echo '<hr /><pre>';
print_r($response->body);
echo '</pre>';
But got this error:
Code:
MailWizzApi_Params Object
(
    [_data:MailWizzApi_Params:private] => Array
        (
            [status] => error
            [error] => Forbidden
        )

    [_readOnly:MailWizzApi_Params:private] =>
)
Best regards
 
sdk config:
Code:
<?php
/**
* This file contains an example of base setup for the MailWizzApi PHP-SDK.
*
* @author Serban George Cristian <cristian.serban@mailwizz.com>
* @link http://www.mailwizz.com/
* @copyright 2013-2015 http://www.mailwizz.com/
*/
//exit('COMMENT ME TO TEST THE EXAMPLES!');
// require the autoloader class
require_once dirname(__FILE__) . '/../MailWizzApi/Autoloader.php';

// register the autoloader.
MailWizzApi_Autoloader::register();

// if using a framework that already uses an autoloading mechanism, like Yii for example,
// you can register the autoloader like:
// Yii::registerAutoloader(array('MailWizzApi_Autoloader', 'autoloader'), true);

/**
* Notes:
* If SSL present on the webhost, the api can be accessed via SSL as well (https://...).
* A self signed SSL certificate will work just fine.
* If the MailWizz powered website doesn't use clean urls,
* make sure your apiUrl has the index.php part of url included, i.e:
* http://www.mailwizz-powered-website.tld/api/index.php
*
* Configuration components:
* The api for the MailWizz EMA is designed to return proper etags when GET requests are made.
* We can use this to cache the request response in order to decrease loading time therefore improving performance.
* In this case, we will need to use a cache component that will store the responses and a file cache will do it just fine.
* Please see MailWizzApi/Cache for a list of available cache components and their usage.
*/

// configuration object
$config = new MailWizzApi_Config(array(
    'apiUrl'        => 'http://iredmail.ir/api/index.php',
    'publicKey'     => '//',
    'privateKey'    => '//',
   
    // components
    'components' => array(
        'cache' => array(
            'class'     => 'MailWizzApi_Cache_File',
            'filesPath' => dirname(__FILE__) . '/../MailWizzApi/Cache/data/cache', // make sure it is writable by webserver
        )
    ),
));

// now inject the configuration and we are ready to make api calls
MailWizzApi_Base::setConfig($config);

// start UTC
date_default_timezone_set('UTC');
my stopping method:
Code:
<?php
/**
* This file contains examples for using the MailWizzApi PHP-SDK.
*
* @author Serban George Cristian <cristian.serban@mailwizz.com>
* @link http://www.mailwizz.com/
* @copyright 2013-2015 http://www.mailwizz.com/
*/
// require the setup which has registered the autoloader
require_once dirname(__FILE__) . '/setup.php';

// CREATE THE ENDPOINT
$endpoint = new MailWizzApi_Endpoint_Campaigns();

// Pause/Unpause CAMPAIGN
$response = $endpoint->pauseUnpause('zv3484c4pj79d');

// DISPLAY RESPONSE
echo '<hr /><pre>';
print_r($response->body);
echo '</pre>';
and my next question:
How is it possible to send campaign to multi list via API (like Campaign extra recipients in creating campaign at mailwizz customer panel)
create method of mailwzz api class :
Code:
$response = $endpoint->create(array(
    'name'          => 'My API Campaign', // required
    'type'          => 'regular', // optional: regular or autoresponder
    'from_name'     => 'John Doe', // required
    'from_email'    => 'john.doe@doe.com', // required
    'subject'       => 'Hey, i am testing the campaigns via API', // required
    'reply_to'      => 'john.doe@doe.com', // required
    'send_at'       => date('Y-m-d H:i:s', strtotime('+10 hours')), // required, this will use the timezone which customer selected
    'list_uid'      => 'LIST-UNIQUE-ID', // required
    'segment_uid'   => 'SEGMENT-UNIQUE-ID',// optional, only to narrow down
And list_uid can't get array :confused:
 
How is it possible stop campaign that request via API? I wan't campaign be draft and after manually checked campaign. do it send manually.
 
I wan't campaign be draft and after manually checked campaign.
Unfortunately the status is set manually in the code, to pending-sending not to draft.
You can create your own campaigns controller that extend the application one, and allow there to set the status based on the post data.
 
Back
Top