-1

I am trying to update a subscriber's status on a (publication) list, however, ET_Patch() doesn't appear to be affecting anything. If a subscriber is on the list with a status of Unsubscribed, I will attempt to update their status to Active by using the following code:

<?php
require(base_path() . '/_includes/ET_Client.php');


$email = '[email protected]';

$etClient = new ET_Client();


$objectType = 'ListSubscriber';
$properties = ['Status', 'ListID'];

$filterSubscriberKey = [
    'Property' => 'SubscriberKey',
    'SimpleOperator' => 'equals',
    'Value' => $email
];

$filterListID = [
    'Property' => 'ListID',
    'SimpleOperator' => 'equals',
    'Value' => 44
];

$filter = [
    'LeftOperand' => $filterSubscriberKey,
    'LogicalOperator' => 'AND',
    'RightOperand' => $filterListID
];

$getSinceLastBatch = false;

$getListsResponse = new ET_Get($etClient, $objectType, $properties, $filter, $getSinceLastBatch);


if ($getListsResponse->results[0]->Status == 'Unsubscribed') {
    $subPatch = new ET_Subscriber();
    $subPatch->authStub = $etClient;
    $subPatch->props = [
        "EmailAddress" => $email,
        'SubscriberKey' => $email,
        'Lists' => ['ID' => 44],
        "Status" => "Active"
    ];
    $patchResult = $subPatch->patch();
}

However, the subscriber's status remains Unsubscribed. Any thoughts?

Thanks.

1 Answer 1

1

Before I posted my question, I took a look at the SOAP envelope as presented in the documentation. Turns out, the Status property is a nested array inside the Lists nested array:

$subPatch = new ET_Subscriber();
$subPatch->authStub = $etClient;
$subPatch->props = [
    "EmailAddress" => $email,
    'SubscriberKey' => $email,
    'Lists' => [
        [
            'ID' => 44,
            'Status' => 'Active'
        ]
    ]
]; 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .