亚马逊MWS连接拒绝FeedSubmit

时间:2016-07-07 20:17:59

标签: php curl amazon-mws

我尝试使用amazon PHP SDK向MWS提交Feed以更新库存。

这是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amznenvelope.xsd">
<Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>MY_MERCHANT_ID</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
    <MessageID>1</MessageID>
    <OperationType>Update</OperationType>
    <Inventory>
        <SKU>MY_SKU</SKU>
        <Quantity>3</Quantity>
        <FulfillmentLatency>1</FulfillmentLatency>
    </Inventory>
</Message>
</AmazonEnvelope>

我的PHP代码:

$service = new MarketplaceWebService_Client(AWS_KEY, AWS_SECRET, CONFIG_FEEDS, APP_NAME, APP_VERSION);

    $feedHandle = @fopen('php://memory', 'rw+');
    fwrite($feedHandle, XML_STRING);
    rewind($feedHandle);

    $request = new MarketplaceWebService_Model_SubmitFeedRequest();
    $request->setMerchant(MERCHANT_ID);
    $request->setMarketplaceIdList(["id" => [MARKET_PLACE_1, MARKET_PLACE_2, MARKET_PLACE_3]]);
    $request->setFeedType($feedType);
    $request->setContentMd5(base64_encode(md5(stream_get_contents($feedHandle), true)));
    rewind($feedHandle);
    $request->setPurgeAndReplace(false);
    $request->setFeedContent($feedHandle);

    rewind($feedHandle);
    $response = $service->submitFeed($request);

当我运行代码时,我得到一个空的错误响应:

Caught Exception: Internal Error 
Response Status Code: 0 
Error Code: 
Error Type: 
Request ID: 
XML: 
RequestId: , 
ResponseContext: , 
Timestamp: 
ResponseHeaderMetadata:

我激活了curl来显示错误,它说:

Failed to connect to mws.amazonservices.com.mx port 80: Connection refused

我读到了有关该问题的信息,并看到了有关更改CURLOPT_SSL_VERIFYPEER选项的答案,我尝试修改该类中的该选项,该类设置Client.php的默认配置为:

private function getDefaultCurlOptions() {
return array (
  CURLOPT_POST => true,
  CURLOPT_USERAGENT => $this->config['UserAgent'],
  CURLOPT_VERBOSE => true,
  CURLOPT_HEADERFUNCTION => array ($this, 'headerCallback'),
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_SSL_VERIFYPEER => false,
  CURLOPT_SSL_VERIFYHOST => 2,
);

还尝试添加我刚刚从Mozilla获得的证书,并将VERIFYPEER设置为true,如下所示:

CURLOPT_CAINFO         => __DIR__ . "/../../../../../cacert.pem"

但没有成功。任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

刚刚意识到我在CONFIG_FEEDS中传递了URL,同时创建了无需httpS连接的客户端:)