Adobe-Marketing-Cloud / marketing-cloud-php-sdk

PHP Library for the Adobe Digital Marketing API
MIT License
35 stars 32 forks source link

Version 1.4 Issues #7

Closed flashbng closed 9 years ago

flashbng commented 10 years ago

I'm currently having problems with querying V1.4 of the Omniture API using this SDK, although V1.3 works just fine. Reason for the upgrade is I'm trying to utilize the ability to stack segments in the API.

When I comment out the V1.4 option, both of the var_dumps return and give me everything I need. However, when I use the option, I get NULL for both.

Any thoughts? Code I'm using is below.



getHttpClient()->setOption('api_version', '1.4');
$adm->authenticate($username, $secret);

$reportApi = $adm->getReportApi();

$response = $reportApi->QueueOvertime(array(
    'reportSuiteID' => 'xxxxxx',
    'dateFrom' => date($start_date),
    'dateTo' => date($end_date),
    'metrics'  => array(
        array('id' => 'visits'),
    ),
    'segments' => '',
));

var_dump($response);
# fetch response from query

$reportId = $response['reportID'];

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

var_dump($report);

?>            
flashbng commented 10 years ago

When I turn on de-bugging, it looks like it's trying to send a POST request to a moved document:

send POST request: https://api.omniture.com/admin/1.4/rest/?method=Report.QueueOvertime

flashbng commented 10 years ago

Anyone looking at this at all? Would be nice to get some feedback from the "official" SDK.

bshaffer commented 10 years ago

This SDK currently only supports 1.3. The Report.QueueOvertime method for 1.4 has been changed to Report.Queue.

One way to get around this is to use the SuiteApi class instead of the ReportApi class. The SuiteApi class is a generic class that can call any 1.4 method easily. This should work for 1.4:

$api = $adm->getSuiteApi();

$response = $api->post('Report.Queue', array('reportDescription' => array(
    'reportSuiteID' => 'xxxxxx',
    'dateFrom' => date($start_date),
    'dateTo' => date($end_date),
    'metrics'  => array(
        array('id' => 'visits'),
    ),
    'segments' => '',
)));

var_dump($response);

#fetch response from query
$reportId = $response['reportID'];

do {
    $report = $api->post('Report.Get', array('reportID' => $reportId));
    sleep(2);
} while (isset($report['error_description']) && $report['error_description'] == 'report_not_ready');

var_dump($report);
flashbng commented 10 years ago

@bshaffer Thank you a ton!

flashbng commented 10 years ago

@bshaffer -- found a small error in the code you provided.

This:


do {
    $report = $api->post('Report.Get', array('reportID' => $reportId));
    sleep(2);
} while (isset($report['error_description']) && $report['error_description'] == 'report_not_ready')
Needs to be this:

do {
    $report = $api->post('Report.Get', array('reportID' => $reportId));
    sleep(2);
} while (isset($report['error_description']) && $report['error_description'] == 'Report not ready');
            
garyr commented 9 years ago

The newest version now supports v1.4 by default