API - Subscribe user to list error

minamoto

New Member
Hi.

I'm trying a simple call to API to subscribe a new user to an existing lists.

PHP:
require_once BASEPATH . "path/to/mailwizz/setup/class/";
$listUid = 'unique_id_of_the_list_in_wizzmail';
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->create($listUid, array(
  'EMAIL' => sanitize($email)
));
$response = $response->body;
  if ($response->itemAt('status') == 'success') {
    DO MY STUFF HERE
  } else {
    DO ERROR STUFF HERE
  }

Long story sort the response from $response->itemAt('error') is "Not Found".
The users is not written in database.

Any help?

Kind Regards
 
Never mind.
Read the documentation again and it seems that I had to add index.php after mydomaincom/api/ when setting apiUrl parameter.

Sorry about that.
Kind Regards.
 
Yes it seems that's there too.

A quick follow up question.

After un-subscribe a user via API(unsubscribeByEmail() function) it sets the status to "Unsubscribed", correct?

How can I set the status back to "Confirmed" without creating new user?
Is it using createUpdate()?
What parameter changes the status and what values can I use?


Kind regards
 
@minamoto - You could try using the update endpoint as follows:
PHP:
$response = $endpoint->update('LIST-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID', array(
    'EMAIL' => 'john.doe@doe.com',
    'FNAME' => 'John',
    'LNAME' => 'Doe Updated',
    'details' => [ 'status' => 'confirmed' ],
));
That should do it.
 
@minamoto - just look in the Endpoints folder, you will see there everything you need.
Well its not exactly clear on the file you pointed about the parameters.
For example update() function in Endpoint/ListSubscribers.php we got
PHP:
'paramsPut'     => $data,
which is not explaining
PHP:
array(
    'EMAIL' => 'john.doe@doe.com',
    'FNAME' => 'John',
    'LNAME' => 'Doe Updated',
    'details' => [ 'status' => 'confirmed' ],
));

So I have to dig deeper on each function to know what the $data should be.

Maybe after I finish the whole process I'll update the git README with all parameters, if you allow me to, of course.

Kind regards
 
Back
Top