3

i am running into an issue with the REST API. I am able to subscribe a user to any list when they are new to the system using ->post(), but when a user is already in our system and unsubscribed from a specific list, I cannot update that user to make them re-subscribed to that specific list.

I have tried ->patch() and ->AddSubscriberToList. in both cases, i get a success message, but the subscribers status does not change.

When using ->patch() it will update user attributes, but not change the subscriber status for a list.

the code i am running. Am i missing something to change the subscriber status? you will see below that i have tried with and without subscriber key, makes no difference.

<?php
$subPatch = new ET_Subscriber();
$subPatch->authStub = $myclient;
$subPatch->props = array('EmailAddress' => $email); //'SubscriberKey' => $email
$subPatch->props['Attributes'] = array(
  //array('Name' => 'firstName', 'Value' => 'BILL'),
  array('Name' => 'Business_Unit', 'Value' => 'sandbox'), 
  array('Name' => 'email_source', 'Value' => 'lightbox-existing'),
);


$enabled_lists = array_filter(variable_get('aaa_email_collector_et_lists', array()));
$subPatch->props['Lists'] = array();
//$list_to_subscribe = array();
foreach ($enabled_lists as $list_id => $list_name) {
  $subPatch->props['Lists'][] = array('ID' => $list_id);
  //$list_to_subscribe[] = $list_id;

}

//$patchResult = $myclient->AddSubscriberToList($email, array('138704'));
$patchResult = $subPatch->patch();
?>
2
  • Where are you actually setting the status? A list needs to have the status property = active for a subscriber.
    – Timothy
    Jun 30, 2014 at 15:54
  • @Timothy, I am not setting the status. I didnt see anywhere in the documentation on how to set the status. When originally adding someone, it automatically sets the status, so I'm not sure how to structure the array to pass status into the call.
    – gmorse
    Jun 30, 2014 at 19:56

1 Answer 1

0

I would try using patch but add an attribute, name => 'status' value => 'active'. Its a hidden attribute that defaults to active which is why it works on an add but not an update.

6
  • so, add that to the "lists" array? or add it to $subPatch->props?
    – gmorse
    Jul 1, 2014 at 16:10
  • add it to $subPatch->props['Attributes'] and let us know what happens.
    – Timothy
    Jul 1, 2014 at 16:49
  • I tried this in many different places, but no luck.
    – gmorse
    Jul 14, 2014 at 13:21
  • 1
    I was just working with something similar on this thread:(salesforce.stackexchange.com/questions/43850/…) Why don't you have a look and see if that helps? Otherwise, post back here.
    – Timothy
    Jul 14, 2014 at 19:57
  • looks promising. ill check it out.
    – gmorse
    Jul 14, 2014 at 21:10

You must log in to answer this question.

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