Amazon MWS API w/ PHP: alternative to getFeedSubmissionResult

天大地大妈咪最大 提交于 2019-12-06 04:43:10

I had the same problem. The issue is that the response returns the result for you to compare the received file against to verify no corruption during transmission. To get xml response with Message you should save it to file not to php://memory. So the next code works for me fine

$filename = __DIR__.'/file.xml';
$handle = fopen($filename, 'w+');
$request = new MarketplaceWebService_Model_GetFeedSubmissionResultRequest();
$request->setMerchant(MERCHANT_ID);
$request->setFeedSubmissionId(ID_TO_CHANGE);
$request->setFeedSubmissionResult($handle);


try {
    $response = $service->getFeedSubmissionResult($request);
    fclose($handle);

    echo ("Service Response\n");
    echo ("=============================================================================\n");

    echo("        GetFeedSubmissionResultResponse\n");
    if ($response->isSetGetFeedSubmissionResultResult()) {
        $getFeedSubmissionResultResult = $response->getGetFeedSubmissionResultResult();
        echo ("            GetFeedSubmissionResult");

        if ($getFeedSubmissionResultResult->isSetContentMd5()) {
            echo ("                ContentMd5");
            echo ("                " . $getFeedSubmissionResultResult->getContentMd5() . "\n");
        }
    }
    if ($response->isSetResponseMetadata()) {
        echo("            ResponseMetadata\n");
        $responseMetadata = $response->getResponseMetadata();
        if ($responseMetadata->isSetRequestId())
        {
            echo("                RequestId\n");
            echo("                    " . $responseMetadata->getRequestId() . "\n");
        }
    }

    echo("            ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
} catch (MarketplaceWebService_Exception $ex) {
    echo("Caught Exception: " . $ex->getMessage() . "\n");
    echo("Response Status Code: " . $ex->getStatusCode() . "\n");
    echo("Error Code: " . $ex->getErrorCode() . "\n");
    echo("Error Type: " . $ex->getErrorType() . "\n");
    echo("Request ID: " . $ex->getRequestId() . "\n");
    echo("XML: " . $ex->getXML() . "\n");
    echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
}

the result you can find in ./file.xml file this helped me

If you do not want to use a file. Then at the end of your try statement.
$xml = stream_get_contents($request->getFeedSubmissionResult());

That will put the xml data into $xml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!