lafourchette/adobe-campaign-client-bundle

Provide access to adobe campaign API

This package's canonical repository appears to be gone and the package has been frozen as a result.

Installs: 16 079

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 40

Forks: 4

Type:symfony-bundle

v1.1.0 2015-11-09 11:49 UTC

This package is not auto-updated.

Last update: 2024-01-20 15:10:20 UTC


README

Build Status Scrutinizer Code Quality Code Coverage

Provide access to adobe campaign SOAP API

Installation

Add AdobeCampaignClientBundle to your composer.json, then update

{
    ...
    "require": {
        "lafourchette/adobe-campaign-client-bundle": "~1.0"
    },
    ...
}

Add AdobeCampaignClientBundle to your application kernel

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new LaFourchette\AdobeCampaignBundle\LaFourchetteAdobeCampaignBundle(),
            // ...
        );
    }

Update your configuration

# app/config/config.yml
adobe_campaign_client:
    base_uri: http://adobe_campaign.uri.com
    login: login
    password: password
    schemas: #A client instance will be created for each schema you need
        query_def:
            name: query_def
            schema: xtk:queryDef

Usage

// Retrieve client service
$client = $container->get('adobe_campaign_client.client.query_def');

// Prepare SOAP envelope
$envelope = <<<EOT
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xtk:queryDef">
  <x:Header/>
  <x:Body>
    <urn:ExecuteQuery>
      <urn:sessiontoken>%s</urn:sessiontoken>
      <entity xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
        <queryDef operation="select" schema="nms:broadLogRcp" xtkschema="xtk:queryDef" lineCount="100">
          <select>
            <node expr="@id"/>
            <node expr="[recipient/@id]"/>
            <node expr="[delivery/@label]"/>
          </select>
          <where>
            <condition expr="[@recipient-id] = %s"/>
          </where>
          <orderBy>
            <node expr="@eventDate" sortDesc="true"/>
          </orderBy>
        </queryDef>
      </entity>
    </urn:ExecuteQuery>
  </x:Body>
</x:Envelope>
EOT;

// Execute SOAP request
$xmlResponse = $client->doCustomSoapRequest(
    sprintf($envelope, $client->getConfiguration()->getSession(), $idCustomer),
    'ExecuteQuery'
);

// Parse results
$campaignList = array();
foreach ($xmlResponse->xpath('/Envelope/Body/ExecuteQueryResponse/pdomOutput/broadLogRcp-collection/broadLogRcp') as $broadLogRcp) {

    $delivery = $broadLogRcp->xpath('delivery');
    $delivery = current($delivery);

    $campaignList[] = array(
        'id' => (int) $broadLogRcp['id'],
        'label' => (string) $delivery['label']
        )
    );
}

return $campaignList;

License

This bundle is under the MIT license.