1

I am trying to make a SOAP request from Drupal to Marketing cloud by trying to integrate the API starter kit (PHP version) - https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/connecting_to_the_api_using_php.htm .

I have used the "Sample PHP Code" section on this page - https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/retrieving_data_from_a_data_extension.htm as a template for my request in Drupal.

Could I be referencing the "exacttarget_soap_client.php" file incorrectly?

The error I am getting is the following:

ParseError: syntax error, unexpected 'CloudSoapClient' (T_STRING) in module_load_include() (line 1303 of /htdocs_20190214/sites/all/modules/custom/b_forms/b_forms.forms.inc).

Line 1303 is " $client = new Marketing CloudSoapClient($wsdl, array('trace'=>1)); " just after " /* Create the Soap Client */ ".

This is the code I have added to my "b_forms.forms.inc" file in the custom module:

    $path = drupal_get_path('module', 'custom');
    require($path . '/b_forms/exacttarget_soap_client.php');
    $wsdl = '[HIDDEN]';
    try     {
            /* Setting variables */
            $soap_endpoint = variable_get('soap_endpoint');
            $soap_username = variable_get('soap_username');
            $soap_userpass = variable_get('soap_userpass');
            /* Create the Soap Client */
            $client = new Marketing CloudSoapClient($wsdl, array('trace'=>1));
            /* Set username and password here */
            $client->username = $soap_username ;
            $client->password = $soap_userpass ;

            $rr = new Marketing Cloud_RetrieveRequest();
            $rr->ObjectType = "DataExtensionObject[HIDDEN]";
            $rr->Properties =  array();
            $rr->Properties[] = "SubscriberID";
            $rr->Properties[] = "FirstName";
            $rr->Properties[] = "Email";

            // Setup a simple filter based on the key column you want to match on
            $sfp= new Marketing Cloud_SimpleFilterPart();
            $sfp->Value =  array($subscriber_email);
            $sfp->SimpleOperator = Marketing Cloud_SimpleOperators::equals;
            $sfp->Property="Email";

            $rr->Filter = new SoapVar($sfp, SOAP_ENC_OBJECT, 'SimpleFilterPart', "http://exacttarget.com/wsdl/partnerAPI");
            $rr->Options = NULL;
            $rrm = new Marketing Cloud_RetrieveRequestMsg();
            $rrm->RetrieveRequest = $rr;
            $results = $client->Retrieve($rrm);
            var_dump($results);

            $subscriber_email = $results->Results->Properties->Property[2]->Value;
            return $subscriber_email;

      } catch (Exception  $e) {
              var_dump($e);
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.