Retrieve Subscribers with “Unsubscribe” Status from List via SOAP API & PHP

1
));
/* Set username and password here */
$client2->username = ‘user’;
$client2->password = ‘password’;
$rr2 = new ExactTarget_RetrieveRequest();
$rr2->ObjectType = ‘ListSubscriber’;

// Set the properties to return

$props2 = array(
“ListID”,
“SubscriberKey”,
“Status”
);
$rr2->Properties = $props2;

// Setup account filtering, to look for a given account MID

$filterPart2 = new ExactTarget_SimpleFilterPart();
$filterPart2->Property = ‘SubscriberKey’;
$values2 = array(
$SearchParam
);
$filterPart2->Value = $values2;
$filterPart2->SimpleOperator = ExactTarget_SimpleOperators::equals;

// Encode the SOAP package

$filterPart2 = new SoapVar($filterPart2, SOAP_ENC_OBJECT, ‘SimpleFilterPart’, “http://exacttarget.com/wsdl/partnerAPI”);

// Set the filter to NULL to return all MIDs, otherwise set to filter object
// $rr2->Filter = NULL;

$rr2->Filter = $filterPart2;

// Setup and execute request

$rr2m = new ExactTarget_RetrieveRequestMsg();
$rr2m->RetrieveRequest = $rr2;
$results2 = $client2->Retrieve($rr2m);
for ($i = 0; $i < count($results2->Results); $i++)
{
if ($results2->Results[$i]->ListID == $myListID)
{
if ($results2->Results[$i]->Status == “Unsubscribed”)
{
$unsubStatus = true;
}
}
}
}

catch(SoapFault $e)
{
/* output the resulting SoapFault upon an error */
var_dump($e);
}
}
?>