How to Setup PHP SDK API?

Ray Li

Member
Hello,
I have read through many threads and searched for steps on how to use the Mailwizz SDK to no success. Can you provide instructions on how to use the SDK? What files do I need and where do I upload the folder to my server?
My goal is to do what was started in this thread: https://forum.mailwizz.com/threads/subscribers-email-through-api.1019/#post-5701
I need to be able to add subscribers to my email list by passing a URL with their email address. I understand how a script can do that but interfacing with the SDK has got me stuck. I am at a loss as to where and how to setup the SDK. Some pointers on the folders I need to add and what parameters needs to be edited would be greatly appreciated.
Note: I am not asking for help on adding a subscriber by passing a URL, just the steps I need to setup the SDK on my server. There really should be a guide somewhere...
 
The steps are exactly the same as described in the examples, that's really all there needs to be to it, there's no need for any kind of extra documents.
You basically need to download the sdk then unzip it and upload the resulted folder on the server. Rename the examples folder into whatever name you wish and remove all the files from it beside the setup.php file.
Edit the setup.php file and put your api details inside, that is URL and Keys.
Create a new file, near the setup.php file, call it test.php and in it put:
PHP:
<?php 
// require the setup which has registered the autoloader
require_once dirname(__FILE__) . '/setup.php';
// CREATE THE ENDPOINT
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
/*===================================================================================*/
// GET ALL ITEMS
$response = $endpoint->getSubscribers('LIST-UNIQUE-ID', $pageNumber = 1, $perPage = 10);
// DISPLAY RESPONSE
echo '<pre>';
print_r($response->body);
echo '</pre>';
Save the file and call it via your browser url.
See the examples folder for any other action you wish to perform using the api.
 
@twisted1919 First, can I confirm that in the above code sample, 'LIST-UNIQUE-ID' should actually be the ID of the list that you are trying to display, correct? Even when I replace that with an actual ID, I get the following error:

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

    [_readOnly:MailWizzApi_Params:private] =>
)

Any ideas on what I might be doing wrong?
 
HELLO, I see API keys (public/private) can be generated for the customers but I want to disable that and only enable API public/private pair for the Owner. That way - I can use my app to trigger new customer process then update his list etc.
 
Got it. Thanks. However - how do I generate key pair for owner? For customer there is a link but owner dashboard doesn't show any.
 
Nevermind - I found your reply. So key pair is not needed to add a customer. Btw - I was able to execute customers.php from php-sdk examples. It did add the customers with status 'pending-confirm'.
I also tried to add
'status' => 'Active',
in the customers.php example but it didn't mark that customer as active. Is there anything else I need to do.
 
Agree. But I don't want it to show me status pending confirm. As soon as I use API to add the customer, I want status "confirmed".
 
How could I enable the api on the mailwizz application. Next how to install it on server side plus the client side.
Can you please suggest the path for the same for server side and client side?
I installed it but it is giving 404 error. How could I fix it?
 
mailmfodaapp@box:~/public_html/apps/common/vendors/Composer/vendor/mailwizz-php-sdk-master$ composer test
> ./vendor/bin/phpunit
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

E

Time: 43 ms, Memory: 4.00 MB

There was 1 error:

1) MailWizzApi_Test_Endpoint_ListsTest::testGetLists
Exception: Please set a valid api base url.

/home/mailmfodaapp/public_html/apps/common/vendors/Composer/vendor/mailwizz-php-sdk-master/MailWizzApi/Config.php:70
/home/mailmfodaapp/public_html/apps/common/vendors/Composer/vendor/mailwizz-php-sdk-master/MailWizzApi/Base.php:290
/home/mailmfodaapp/public_html/apps/common/vendors/Composer/vendor/mailwizz-php-sdk-master/MailWizzApi/Config.php:51
/home/mailmfodaapp/public_html/apps/common/vendors/Composer/vendor/mailwizz-php-sdk-master/MailWizzApi/Test/Base.php:17

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Script ./vendor/bin/phpunit handling the test event returned with error code 2
mailmfodaapp@box:~/public_html/apps/common/vendors/Composer/vendor/mailwizz-php-sdk-master$
 
@mfodamail - what you're doing is wrong. You don't need to touch the php sdk that comes with mailwizz itself.
The PHP SDK is used if you need to talk to your mailwizz app from another server, and it's on that other server where you install it.
I suggest you get in touch with a developer to help you with all this.
 
@twisted1919

We required help for the mailwizz and you are supposing to tell just hire developer. Instead of saying ping the proper step to do setup od mailwizz and where we need to make changes. then how to save values in ENV. Its your duty to say it. We are supposing the support from you.and its your jobs to guide us properly.

@mfodamail

 
Back
Top