API pass subscriber IP Address

Mike Darling

New Member
I'm using the SDK/API to create/add new subscribers to a list each time a subscriber submits a form on one of my websites. (This is not the standard MW form for the list as there is a lot of unrelated functionality and processing happening in the script, thus I'm using the API to add the subscriber to the MW list as a final step).

The problem is that the IP Address associated with each added subscriber is my server IP. It appears that only Custom Fields for a list may be passed via the "create" end point. Is there a way to also pass the subscriber's IP address?
 
@Mike Darling - Yes there's a way to do this, pass a details array to the api call as follows:
Code:
'EMAIL' => 'a@a.com',
'details' => array('ip_address' => '123.123.123.123'),
 
@SirNight - you can pass the IP address to mw:
PHP:
$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',
   'details' => [ 'ip_address' => 'add.ip.address.here' ]
));
 
@SirNight - for the ajax subscribe example:
PHP:
$response = $endpoint->create($listUid, array(
'EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : null,
'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : null,
'LNAME' => isset($_POST['LNAME']) ? $_POST['LNAME'] : null,
'details' => [ 'ip_address' => $_SERVER['REMOTE_ADDR'] ]
));
 
They have updates the system and it over write the passed IP.. so unless you update the code to accept details ip_address override it wont work..
 
Back
Top