superlever
New Member
So I figured out how to subscribe via the API. But now I want to update via the API, but it doesn't seem to work with the code I have (see below).
I can't store the user ID, but the email address should be the unique key. It's just updating the subscriber using the email address.
This is more or less my subscribe code, but I hoped that changing create to update would magically work. It doesn't.
Thanks for your help.
I can't store the user ID, but the email address should be the unique key. It's just updating the subscriber using the email address.
This is more or less my subscribe code, but I hoped that changing create to update would magically work. It doesn't.
Thanks for your help.
PHP:
<?php
// sub.php file
require_once dirname(__FILE__) . '/setup.php';
$listUid = 'xxxxxxx';// 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');
$username = getCleanParam('username');
$os = getCleanParam('os');
$gender = getCleanParam('gender');
$cntry = getCleanParam('country');
$usertype = getCleanParam('usertype');
$socialconnected = getCleanParam('socialconnected');
$interestsadded = getCleanParam('interestsadded');
$endpoint = new MailWizzApi_Endpoint_ListSubscribers();
$response = $endpoint->update($listUid, array(
'EMAIL' => $email,
'FNAME' => $fname,
'LNAME' => $lname,
'USERNAME' => $username,
'OS' => $os,
'GENDER' => $gender,
'CNTRY' => $cntry,
'USERTYPE' => $usertype,
'SOCIALCONNECTED' => $socialconnected,
'INTERESTSADDED' => $interestsadded,
));
function getCleanParam($param, $filter=FILTER_SANITIZE_STRING, $default="")
{
$out = isset($_GET[$param]) && filter_var($_GET[$param], $filter) ? $_GET[$param] : $default;
return $out;
}