1

I'm trying to add some contacts using the php wrapper of the getresponse mailer. On their official API docs, it says addContacts() should return a code and a message, but in my case, it returns NULL, which has grown quite upsetting. I can't really see my mistake.

Many thanks in advance.

Notes:

  • The second case of the if returns an empty array.
  • I've checked the variables literally dozens of times and they're correct.
  • I've tried three different email addresses, but to no avail.

Here's the code:

require_once('GetResponseAPI.class.php');
$api = new GetResponse('apikey'); //triple checked. it is correct

echo '<pre>';
var_dump($_GET);
if($_GET['action_type'] == "register_new"){
    $response = $api->addContact($_GET['campaign_id'], "john smith", $_GET['email']);
    var_dump($response);
}else if($_GET['action_type'] == "check_existance"){
    $contacts   = (array)$api->getContacts((array)$_GET['campaign_id']);
    var_dump($contacts);
}

echo '</pre>';
Tudor Leustean
  • 517
  • 3
  • 15
  • I have the exact same problem, checked it as well dozens of times and all other function do work. Just addContact returns NULL. Did you found a solution? – Snowball Aug 25 '15 at 11:33

1 Answers1

0

Seems like you got the answer yourself, but I will document it here for others.

GetResponse rejects IPv6 addresses. In the old wrapper the IP was defined by $_SERVER['REMOTE_ADDR'] and in some cases (for example if you use xampp or MAMP) this returns an IPv6 address.

Anyway the wrapper has been updated since and now there is an additional function that checks if the IP is valid.

Snowball
  • 1,402
  • 2
  • 17
  • 31
  • Yea, i posted a brief explanation, but the moderator deleted my answer because it was barely a link. Again, I dugged into the wrapper's code and I found out that the errors don't get printed, which explains why the returned value didn't match the expected ones, as stated on the getresponse APIwebsite. What happened in my case, was that $_SERVER['REMOTE_ADDR'] - the method you use to get the IP - returned ":", which getresponse's API sees as an invalid parameter. https://github.com/robertstaddon/GetResponse-PHP-Wrapper/commits?author=VanTudor I fixed it and they also merged my solution. – Tudor Leustean Jan 12 '16 at 16:32