2017 © Pedro Peláez
 

library marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

image

adobe-marketing-cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  • Tuesday, March 27, 2018
  • by bshaffer
  • Repository
  • 27 Watchers
  • 33 Stars
  • 27,614 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 25 Forks
  • 5 Open issues
  • 10 Versions
  • 18 % Grown

The README.md

Adobe Marketing Cloud PHP SDK

Build Status, (*1)

A simple, Object Oriented wrapper for the Adobe Marketing Cloud APIs written in PHP5. This library is modeled after the php-github-api library built by ornicar, (*2)

Uses the Adobe Marketing Cloud APIs. Default version is 1.4, but 1.3 and 1.2 are compatible., (*3)

Requires, (*4)

  • PHP 5.3 or higher
  • php curl but it is possible to write another transport layer..

If the method you need does not exist yet, don't hesitate to request it with an issue!, (*5)

Autoload

The first step to use include the library via composer:, (*6)

require_once '/vendor/autoload.php';

Instantiate a new AdobeMarketingCloud Client

$adm = new AdobeMarketingCloud\Client();

From this object you can now access all of the different AdobeMarketingCloud APIs (listed below), (*7)

Authenticate a user

Authenticate using your Adobe Digital Marketing Web Services username and secret. You can obtain one by logging into the Marketing Cloud and browsing to Admin > Company > Web Services, (*8)

$adm->authenticate($username, $secret);

Note: If authentication fails, it's probably because your company endpoint is different from the default. To verify, this, call the getEndpoint() method:, (*9)

echo $adm->getCompanyApi()->getEndpoint('My Company Name');
// "https://api2.omniture.com"

If the return value of this function is different from https:api.omniture.com, you will need to set the endpoint in your client, (*10)

$adm->setEndpoint('https://api2.omniture.com');

Deauthenticate a user

Cancels authentication., (*11)

$adm->deAuthenticate();

Next requests will not be authenticated, (*12)

Reports

For queueing SiteCatalyst reports Wraps SiteCatalyst Report API., (*13)

$reportApi = $adm->getReportApi();

Run a Ranked Report

$response = $reportApi->queueReport(array(
    'reportSuiteID' => 'your-id',
    'date'     => date('Y-m-d'),
    'metrics'  => array(
        array('id' => 'pageviews'),
    ),
    'elements' => array(
        array('id' => 'eVar1'),
    ),
));

print_r($response);

The above code will render the status of your queued report, which will look something like this:, (*14)

Array
(
  [status]    => ready
  [statusMsg] => Your report has been queued
  [reportID] => 123456789
)

Retrieve a Queued Report

Once the report ID is retrieved for the trended, ranked, or overtime report, use the Report.GetReport API call to retrieve the report, (*15)

$response = $reportApi->queueReport(array(
    //... (see above)
));

$reportId = $response['reportID'];

do {
    $report = $reportApi->getReport($reportId);
    sleep(2);
} while ($report['status'] == 'not ready');

print_r($report['report']);

The above code will render the Report array, which will look something like this:, (*16)

Array
(
    [reportSuite] => Array (
        [id]      => your-id
        [name]    => Your Report Suite
    )
    [period]      => "Mon. 16 July 2012",
    [elements]    => Array (
        [id]      => eVar2,
        [name]    => eVar 2
    )
    [metrics]     => Array (
        [id]      => event2
        [name]    => Page View Event
        [type]    => number
    )
    [type]        => trended
    [data]        => Array (
        ...
    )
    [totals]      => Array (
        ...
    )
)

Returns an array of results as described in the documentation, (*17)

Calling Additional Methods

All the methods visible in the API Explorer can be called using the SuiteApi class. This is a generic class that accepts the method name and parameters, and will return the json encoded response of the result., (*18)

$adm->getSuiteApi()->post('Saint.ExportCreateJob', $parameters);

Curl Debugging

If a request returns null, call the getLastResponse method on the client in order to see the curl information and raw response:, (*19)

if (!$response = $adm->getReportApi()->getReport($reportId)) {
  print_r($adm->getLastResponse());
}

Passing in the debug flag to the HttpClient will output the response automatically when the response does not exist, or is not in json format, (*20)

$adm = new AdobeMarketingCloud\Client(
  new AdobeMarketingCloud\HttpClient\Curl(array('debug' => true))
);

Command Line Utility

OAuth is not yet available for production use. This functionality is still under development., (*21)

The easiest way to begin with OAuth is by using the command line utility tool (bin/adm)., (*22)

To get started, copy over the configuration file:, (*23)

$ cp config/profile.json.dist config/profile.json

Once this is done, run the adm command to get started, (*24)

$ ./bin/amc

Calls the Adobe Marketing Cloud APIs
To get started, call

    $ amc authorize

to retrieve a token.  Some other options available are

 -h, --help      Display a help message and exit
 -v, --version   Display the current api version
 -e, --endpoint  Specify the api endpoint

See developer.omniture.com for more information

The first step will be to get an oauth token. This can be accomplished by providing the authorize command with a client id, client secret, username and password. Client IDs can be created in the Developer Connection. Once you've done this, run the authorize command to receive a token:, (*25)

$ adm authorize CLIENT_ID CLIENT_SECRET USERNAME PASSWORD
Token: {
  "access_token":"f9f071ca2c25d23eff01a1ea238d6f85666be0f6",
  "expires_in":2592000,
  "token_type":"bearer",
  "scope":null,
  "success":true
}

You've now received your first access token. This has been saved to config/profile.json, so you don't need to worry about it. You can go ahead and start making requests!, (*26)

$ adm request Company.GetReportSuites
Array
(
   [report_suites] => Array
       (
           [0] => Array
               (
                   [rsid] => your.rsid
                   [site_title] => Your Site
               )
           ...
       )
)

Endpoints

The default endpoint is api.omniture.com. If you are experiencing issues, call the Company.GetEndpoint method to find out which endpoint you should be using:, (*27)

$ ./bin/adm Company.GetEndpoint 'company=My Company'
https://api2.omniture.com/admin/1.3/rest/

In this case, the endpoint is api2.omniture.com. To use this endpoint instead, set the endpoint in your profile:, (*28)

$ ./bin/amc profile endpoint api2.omniture.com
default value for "endpoint" set to api2.omniture.com

Now all subsequent requests will use this endpoint. If you need to use an endpoint other than the default, you can pass this in with the -e or --endpoint options, (*29)

$ ./bin/amc authorize CLIENT_ID CLIENT_SECRET USERNAME PASSWORD --endpoint 'api3.omniture.com'

To Do

Better documentation and test coverage will be coming soon, (*30)

The Versions

27/03 2018

dev-master

9999999-dev http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

27/03 2018

2.1.2

2.1.2.0 http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

27/03 2018

dev-stevja1-ci-fix

dev-stevja1-ci-fix http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

30/11 2017

2.1.1

2.1.1.0 http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

02/05 2016

2.1.0

2.1.0.0 http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

16/06 2015

2.0.4

2.0.4.0 http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

27/05 2015

2.0.3

2.0.3.0 http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

20/03 2015

2.0.2

2.0.2.0 http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

23/05 2014

dev-php-5.2

dev-php-5.2 http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite

23/05 2014

1.0.0

1.0.0.0 http://github.com/Adobe-Marketing-Cloud/marketing-cloud-php-sdk

An Object Oriented wrapper for the Adobe Marketing Cloud APIs

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

marketing cloud adobe omniture marketing cloud digital suite digital marketing suite