Subscribers Email Through API

Exactly, you have to also edit the setup.php file to add your API info then when you submit that form, the info will be sent to your mailwizz app.
 
Even simpler:
PHP:
// sub.php file
require_once dirname(__FILE__) . '/setup.php';
$listUid = 'LIST-UNIQUE-ID';// you'll take this from your customers area, in list overview from the address bar.

$email  = isset($_GET['email']) && filter_var($_GET['email'], FILTER_VALIDATE_EMAIL) ? $_GET['email'] : null;
if (!$email) {
   exit;
}

$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->create($listUid, array(
     'EMAIL' => $email,
));
Then simply accessing http://www.example.com/sub.php?email=whatever@domain.com will send your subscriber to mailwizz.
Again, you need some PHP understanding to use the SDK.
 
This doesn't work by the way. I'm trying to debug it at the moment. It looks like it breaks REST.
MailWizzApi_Endpoint_ListSubscribers->create requires a POST. We're using a GET. Not sure if it's that though. All I know is, there is no new subscriber in mw_list_subscriber.

I'm using PHPStorm - I can easily step through process - tell me what I should be looking for on access of this URI. Also should the accessor be logged in or better if they're logged out (I'm using xdebug so I'll log out on firefox and run the stepping from there.)
 
@Simon Brown
As long as you call :
PHP:
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->create($listUid, array(
 'EMAIL' => $email,
));
It does not matter that the data comes in your script from GET or from POST, because you take it and while calling the above, mailwizz sdk will do a POST request.

If the SDK fails to do something, then you should get a proper error message. What is it?
 
The code I'm running is this:

Code:
<?php
// sub.php file
require_once dirname(__FILE__) . '/setup.php';
$listUid = 'jz3528x6ez7b1';// you'll take this from your customers area, in list overview from the address bar.
$email = getCleanParam('email', FILTER_VALIDATE_EMAIL, null);
if (!$email) {
    exit;
}
$fname = getCleanParam('fname');
$lname = getCleanParam('lname');
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->create($listUid, array(
    'EMAIL' => $email,
    'FNAME' => $fname,
    'LNAME' => $lname,
));
function getCleanParam($param, $filter=FILTER_SANITIZE_STRING, $default="") 
{
    $out = isset($_GET[$param]) && filter_var($_GET[$param], $filter) ? $_GET[$param] : $default;
    return $out;
}

No error message.

When I visit http://email.artisansend.co.uk/api-access/my_client/lists.php I get:

Code:
MailWizzApi_Params Object
(
[_data:MailWizzApi_Params:private] => Array
(
[status] => error
[error] => Not Found
)

[_readOnly:MailWizzApi_Params:private] =>
)

MailWizzApi_Params Object
(
[_data:MailWizzApi_Params:private] => Array
(
[status] => error
[error] => Not Found
)

[_readOnly:MailWizzApi_Params:private] =>
)

MailWizzApi_Params Object
(
[_data:MailWizzApi_Params:private] => Array
(
[status] => error
[error] => Not Found
)

[_readOnly:MailWizzApi_Params:private] =>
)

MailWizzApi_Params Object
(
[_data:MailWizzApi_Params:private] => Array
(
[status] => error
[error] => Method Not Allowed
)

[_readOnly:MailWizzApi_Params:private] =>
)
 
P.S:
Code:
$fname = getCleanParam('fname');
$lname = getCleanParam('lname');
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->create($listUid, array(
'EMAIL' => $email,
'FNAME' => $fname,
'LNAME' => $lname,
));
You should do a var_dump on $response to see the actual response message.
 
Code:
$config = new MailWizzApi_Config(array(
'apiUrl' => 'http://email.artisansend.co.uk/api',
'publicKey' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'privateKey' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
// components
'components' => array(
'cache' => array(
'class' => 'MailWizzApi_Cache_File',
'filesPath' => dirname(__FILE__) . '/MailWizzApi/Cache/data/cache', // make sure it is writable by webserver
)
),
));

I moved everything up 1 directory from examples and changed $config['filespath'] accordingly.

Yeah I'll var_dump $response, I appreciate you can't see my PHPStorm debug window ;)
 
got something:

Your app doesn't use .htaccess and url rewriting does it...

Because when I have the config like that (see above) var_dump does this:

Code:
object(MailWizzApi_Http_Response)[16]
public 'url' => string 'http://email.artisansend.co.uk/api/lists/jz3528x6ez7b1/subscribers' (length=66)
public 'headers' => null
public 'contentType' => string 'text/html; charset=utf-8' (length=24)
public 'httpMessage' => string 'Not Found' (length=9)
public 'curlCode' => int 0
public 'curlMessage' => string '' (length=0)
public 'storeCurlInfo' => boolean false
public 'curlInfo' => null
public 'body' =>
object(MailWizzApi_Params)[14]
private '_data' =>
array (size=2)
'status' => string 'error' (length=5)
'error' => string 'Not Found' (length=9)
private '_readOnly' => boolean false
public 'request' => null
private '_httpCode' => int 404

And when I put the name of the index file in there, I get this:
Code:
object(MailWizzApi_Http_Response)[16]
public 'url' => string 'http://email.artisansend.co.uk/api/index.php/lists/jz3528x6ez7b1/subscribers' (length=76)
public 'headers' => null
public 'contentType' => string 'application/json; charset=UTF-8' (length=31)
public 'httpMessage' => string 'Created' (length=7)
public 'curlCode' => int 0
public 'curlMessage' => string '' (length=0)
public 'storeCurlInfo' => boolean false
public 'curlInfo' => null
public 'body' =>
object(MailWizzApi_Params)[14]
private '_data' =>
array (size=1)
'status' => string 'success' (length=7)
private '_readOnly' => boolean false
public 'request' => null
private '_httpCode' => int 201

And the user is in the database :)

Thank you for your help
 
How do I ensure security - how do I make sure that only the correct person can operate this API? Is there any authentication in place that can do this? We put the public and private keys into setup.php on the server - is that secure? That means anyone with access to the server could potentially run the code and add subscribers. I'm also building an API URI for removing subscribers, that definitely needs authentication. How is this done?
 
Thank @twisted1919

And i want insert FullName, How to insert filter fullname? Thank you

Even simpler:
PHP:
// sub.php file
require_once dirname(__FILE__) . '/setup.php';
$listUid = 'LIST-UNIQUE-ID';// you'll take this from your customers area, in list overview from the address bar.

$email  = isset($_GET['email']) && filter_var($_GET['email'], FILTER_VALIDATE_EMAIL) ? $_GET['email'] : null;
if (!$email) {
   exit;
}

$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->create($listUid, array(
     'EMAIL' => $email,
));
Then simply accessing http://www.example.com/sub.php?email=whatever@domain.com will send your subscriber to mailwizz.
Again, you need some PHP understanding to use the SDK.
 
@Martino Hugo - If in your list exist custom tag for full name simply add tag name in your code:
PHP:
$response = $endpoint->create($listUid, array(
     'EMAIL' => $email,
     'FULLNAME' => $fullname
));
 
I have installed via composer and set the public key and private key on setup.php.

From the customer end, I have created a list with 2 subscribers.

How can I get the lists from API? What will be the API Endpoint URL to access from the POSTMAN?

I am unable to proceed further without knowing the API URL.

Simply, how can I access the lists/campaign from the vendor example folder?
 
Hi Support

We are getting error, once send http post, request our post url is look like

{"status":"error","error":"Invalid API request params. Please refer to the documentation."}


Please guide how can i post data properly in Mailwizz using http Post/Get request, I need to setup something within my mailwizz or its prebuild - Can you please
guide how can send data by http post request

Thanks
 
We are getting error, once send http post, request our post url is look like
https://host.example.com/index.php/lists/yx3282rbv833a/subscribers/create?EMAIL=kevintaostestemail@email.com&FNAME=Kelvin&LNAME=Pao
{"status":"error","error":"Invalid API request params. Please refer to the documentation."}
Try to remove /create from your url. Make it: https://host.example.com/index.php/lists/yx3282rbv833a/subscribers?EMAIL=kevintaostestemail@email.com&FNAME=Kelvin&LNAME=Pao
 
Back
Top