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
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);

Link to comment
Share on other sites

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

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.