API - Not able to Ass Subscribe to Existing List

Jukkis

New Member
I have been trying to get MailList API to work. Have created php script called addemail.php.
The script has the following:-

// require the setup which has registered the autoloader
require_once dirname(__FILE__) . '/setup.php';

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

$list_unique_id = "xl114yr8tp732";

// ADD SUBSCRIBER
$response = $endpoint->create($list_unique_id, array(
'EMAIL' => 'john.doe@doe.com', // the confirmation email will be sent!!! Use valid email address
'FNAME' => 'John',
'LNAME' => 'Doe'
));

// DISPLAY RESPONSE
echo '<hr /><pre>';
print_r($response->body);
echo '</pre>';

The setup.php has been configured with
// configuration object
$config = new MailWizzApi_Config(array(
'apiUrl' => 'http://www.mydomain.com/mailwizz/api',
'publicKey' => 'public_key',
'privateKey' => 'private_key',

// components
'components' => array(
'cache' => array(
'class' => 'MailWizzApi_Cache_File',
'filesPath' => dirname(__FILE__) . '/MailWizzApi/Cache/data/cache', // make sure it is writable by webserver
)
),
));

I have made the cache folder writable with chmod -R 777 cache command.

When I run the addemail.php, it seems to run it, but the web-page remain blank after the run.

I then expanded the addemail.php to try to read the existing users from an other list:-

// GET ALL ITEMS
$response = $endpoint->getSubscribers($list_unique_id, $pageNumber = 1, $perPage = 10);

// DISPLAY RESPONSE
echo "ALL USERS:</br>";
echo '<pre>';
print_r($response->body);
echo '</pre>';

echo "SCRIPT COMPLETE";

--> Again the script just produces a "white page", even text "SCRIPT COMPLETE" is not outputted to the page.

Any ideas what could be wrong / what should I check.
 
Make:
PHP:
// add code start
error_reporting(-1);
ini_set('display_errors', 1);
// add code end

// require the setup which has registered the autoloader
require_once dirname(__FILE__) . '/setup.php';

Then try again, this time you should see the error message.
 
Added Error-Reporting, nothing still on the web-page, just white screen.
Chrome developer tool console does not show any errors.
My apologies for the typo in the header 'Add'
 
Now re-created the folder structure..
[root]/mailwizz where all files reside
[root]/mailwizz/examples/ - API examples
[root]/MailWizzApi - API files


Modified examples/list_subscribers.php to subscribers.php

Which now has the following code:-
// 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('xv523rps1b5da', $pageNumber = 1, $perPage = 10);
// DISPLAY RESPONSE
echo '<pre>';
print_r($response->body);
echo '</pre>';


And when running the subscribers.php file get the following reply :-

MailWizzApi_Params Object
(
[_data:MailWizzApi_Params:private] => Array
(
[status] => error
[error] => Peer certificate cannot be authenticated with known CA certificates
)

[_readOnly:MailWizzApi_Params:private] =>
)


Adding
// add code start
error_reporting(-1);
ini_set('display_errors', 1);


Will not give any extra information.
 
Could this me something to do with the cURL and CA certificates on my CentOS 6.10 installation (that was recently updated to support TLS1.2)
 
Checked my CA-certificates, and they should be the latest version..
---------
Package ca-certificates-2018.2.22-65.1.el6.noarch already installed and latest version
Nothing to do
--------
The API keys are also correct, so perhaps somebody could give other suggestions for the fix.
 
@Jukkis - open a support ticket with ftp details so we can have a look. Do not post private info in tickets, use safeshare.io and create a secure note.
 
The issue was that the cURL was reporting CA-certificates missing. In the further cURL tests it was found that cURL was working fine to external sites but not to the internal site. In the end we got it working, was talking to hosting support and they found following
----
I had a look at your VM and could see you have a bunch of manual host entries. As your server is behind our cloud firewall, the server itself doesn't know about it's public IP, only it's internal IP. After altering the host entries as below, the test is working as expected.
-------
Maybe some help to someone else!
 
Could I get a sample of the complete working code to add a subscriber through mailwizz api, please? I'm also struggling to get it working. FYI, had no trouble doing same with aweber api - sample code worked out of the box.
 
Back
Top