Setting up the DasGoot API and injecting customers in to lists
PHP Example of setting up and testing your API Injector
Injecting subscribers into the Dasgoot system is very easy. The API builds a GET request which is dependent
on CURL so ensure your PHP distribution has this enabled and you can successfully make a request using it.
To test the Api just follow these simple steps.
1) Download the MailWhizzApi code base on to your server.
2) Edit the setup file
Obtain the correct public and private key values from DasGoot and edit the config array as shown.
To obtain API keys, log in to your DasGoot system, go to API Keys and then click Generate New.
$config = new MailWizzApi_Config(array( 'apiUrl' => 'http://dasgoot.co.uk/MailWizz/api/index.php', 'publicKey' => '[PUBLIC_KEY]', 'privateKey' => '[PRIVATE_KEY]',
3) Edit the configuration file
Change the following lines to the correct key values supplied by DasGoot
public $publicKey = '[PUBLIC_KEY]'; /** * @var string the api private key. */ public $privateKey ='[PRIVATE_KEY]';
4) Create a test using the MailWhizzApi
You will need to enter the correct subscriber list code, this can be found in your DasGoot account by clicking on the list
you want to inject customers to. If you click on lists overview you will see a URL similar to
/index.php/lists/rb601x2x7x45e/overview – where rb601x2x7x45e will be the subscriber list code.
The code below is saved as the test.php file in the example directory.
<?php // require the setup which has registered the autoloader require_once dirname(__FILE__) . '/Config.php'; // CREATE THE ENDPOINT $endpoint = new MailWizzApi_Endpoint_ListSubscribers(); $response = $endpoint->create('<subscriber list code>', array( 'EMAIL' => 'firstname.lastname@example.org', // the confirmation email will be sent if set!!! Use valid email address 'FNAME' => 'John', 'LNAME' => 'Doe' )); print_r($response->body); php?>
5) Run your script
You’ll need to ensure your test file is accessible from a web browser. Then just call it in the normal way.
You’ll see a favourable message from the print_r dump if all is well.
DasGoot will prevent duplication of the subscriber so you will only see this message once.