2

I have created a function to handle a retrieve request using the ExactTarget API with PHP. The problem is that there's no documentation for using Complex Filter Parts in retrieve requests using the PHP version of the API. Here is my code. Please let me know if you spot any issues with why the ComplexFilterPart object is not working. Thanks!

$request = new ExactTarget_RetrieveRequest();
$request->ObjectType = 'ListSubscriber';
$request->Properties = array('ObjectID', 'SubscriberKey', 'CreatedDate', 'ModifiedDate', 'Client.ID', 'Client.PartnerClientKey', 'ListID', 'Status', 'UnsubscribedDate', 'ID');
$request->Filter = array();

$filterSubscriberKey = new ExactTarget_SimpleFilterPart();
$filterSubscriberKey->Property = 'SubscriberKey';
$filterSubscriberKey->SimpleOperator = ExactTarget_SimpleOperators::equals;
$filterSubscriberKey->Value = array($subscriberEmailAddress);

$filterListSubscriberStatus = new ExactTarget_SimpleFilterPart();
$filterListSubscriberStatus->Property = 'Status';
$filterListSubscriberStatus->SimpleOperator = ExactTarget_SimpleOperators::equals;
$filterListSubscriberStatus->Value = array('Active');

$filterGroup = new ExactTarget_ComplexFilterPart();
$filterGroup->LeftOperand = $filterSubscriberKey;
$filterGroup->LogicalOperator = ExactTarget_LogicalOperators::_AND;
$filterGroup->RightOperand = $filterListSubscriberStatus;

$request->Filter = new SoapVar($filterGroup, SOAP_ENC_OBJECT, 'ComplexFilterPart', 'http://exacttarget.com/wsdl/partnerAPI');

$requestMsg = new ExactTarget_RetrieveRequestMsg();
$requestMsg->RetrieveRequest = $request;
$results = $client->Retrieve($requestMsg);

$subscriberLists = $results->Results;
1

2 Answers 2

2

The SimpleFiltersParts need to be SOAP encoded.

Example:

$filterGroup = new ExactTarget_ComplexFilterPart();
$filterGroup->LeftOperand = new SoapVar($filterSubscriberKey, SOAP_ENC_OBJECT, 'SimpleFilterPart', 'http://exacttarget.com/wsdl/partnerAPI');
$filterGroup->LogicalOperator = ExactTarget_LogicalOperators::_AND;
$filterGroup->RightOperand = new SoapVar($filterListSubscriberStatus, SOAP_ENC_OBJECT, 'SimpleFilterPart', 'http://exacttarget.com/wsdl/partnerAPI');

Full working example of a complex filter with the Subscriber object can be found at: https://github.com/MichaelAllenClark/exacttarget-soap-php/blob/master/samples/retrieve_subscriber.php

3
  • Swing and a miss on my part. I had some of it :) Thanks @Mac! Mar 26, 2014 at 12:38
  • Thank you for your support. You got the fix. It was that the SimpleFilterParts needed to be SOAP encoded! It works like a charm. Thanks again.
    – Axiom
    Mar 27, 2014 at 16:31
  • How to do it with fuel SDK? Is it possible only via SOAP?
    – koalaok
    Oct 19, 2017 at 14:42
2

I believe the equals SimpleOperator is expecting a string here.

Try:

$filterSubscriberKey->Value = $subscriberEmailAddress;

And:

$filterListSubscriberStatus->Value = 'Active';

If you want to use an array, try using Contains or Like.

You must log in to answer this question.

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