Jump to content

Parsing array GetReportListSample


holepro

Recommended Posts

I'm a PHP newbie and trying to get addressability to an Amazon sample program  GetReportListSample

found in amazon-mws-v20090101-php-2011-08-01._V147626421_.zip

 

I successfully get the data from the following:

 

                    invokeGetReportList($service, $request);

 

The following data is returned as

****

Service Response

=============================================================================

        GetReportListResponse

            GetReportListResult

                HasNext

 

                ReportInfo

                    ReportId

                        6014247793

                    ReportType

                        _GET_ORDERS_DATA_

                    ReportRequestId

                        5013134548

                    AvailableDate

                        2012-03-24T20:01:41Z

                    Acknowledged

****

 

I'm trying to figure out the code on how to get the value (6014247793) in the ReportInfo->ReportId->6014247793 location.

 

I have unsuccessfully tried different scenarios of "foreach" which may not be the right method to use

 

If anyone can point me in a direction to get the results into an array, I'd appreciate it.

 

Thanks in advance for your help

 

Peggy

Link to comment
https://forums.phpfreaks.com/topic/264077-parsing-array-getreportlistsample/
Share on other sites

Can you post what you have tried?

 

One approach is to cast the result to an array, eg:

 

$result = (array) $result;

 

This will only convert one level to an array, and must be repeated at each level.

 

The other thing that would help us to help you is to post a var_dump() of the result.  You can get that like this:

 

print "<pre>";
var_dump($result);

Thanks for the response.

 

I just figured out my problem that had been staring me in the face for a very long time.

 

The function  --    function invokeGetReportList(MarketplaceWebService_Interface $service, $request)

 

Had 'echos'  to print out the values coming back including the headers for the value.

 

I have now created an array within the function and directly pass the value into the array

 

 

***

 

  foreach ($reportInfoList as $reportInfo) {

                        echo("                ReportInfo\n");

                        if ($reportInfo->isSetReportId())

                        {

                            echo("                    ReportId\n");

                            echo("                        " . $reportInfo->getReportId() . "\n");

                            $azreports[$i]=$reportInfo->getReportId() ;

                            $i++;

 

** 

 

The above code isn't working yet,  but I'm fairly certain I'm moving in the right direction, and I should have figured this out before posting this question, but I'm a novice PHP programmer and know enough to be dangerous.

 

Closing out this problem/question.

 

Thanks for your comments again

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.