iContact api subscribe contact to list

1.1k Views Asked by At

I'm trying to integrate iContact api with wordpress and I need to add/move/delete contacts in lists under certain circumstances. I can add contact with addContact() method. But when I'm trying to subscribe contact via subscribeContactToList($iContactId, $iListId, $sStatus) method, it doesn't work and returns me an emty array.

It seems I'm doing everything according to following example: https://github.com/icontact/icontact-api-php/blob/master/examples.php. I haven't any idea how can get it to work.

What am I doing wrong? Has anyone faced with such problem and which is the most proper way to tackle it?

Here is my code:

// Load the iContact library
require_once('icontact/iContactApi.php');
// configuring iContact API
iContactApi::getInstance()->setConfig(array(
    'appId'       => '',
    'apiPassword' => '',
    'apiUsername' => ''
));
$oiContact = iContactApi::getInstance();
$contactInfo = $oiContact->addContact(
                        $user->user_email,
                        'normal',  
                        null, 
                        $first_name, 
                        $last_name, 
                        null, 
                        null, 
                        null, 
                        null, 
                        null, 
                        null, 
                        null, 
                        null, 
                        null
                    );
$oiContact->subscribeContactToList($contactInfo->contactId, $list_id, 'normal');
1

There are 1 best solutions below

0
On

It is possible you have used invalid listID.

You can use the function getLists() to get correct ID.

var_dump($oiContact->getLists());

It normally returns nothing when invalid ID happen.