使用Amazon MWS商户履行API PHP SDK购买航运服务
我正试图使用亚马逊MWS商户实现API PHP SDK来购买航运 我的代码如下所示,为保护隐私,更改了一些个人详细信息:使用Amazon MWS商户履行API PHP SDK购买航运服务,php,api,sdk,amazon-mws,Php,Api,Sdk,Amazon Mws,我正试图使用亚马逊MWS商户实现API PHP SDK来购买航运 我的代码如下所示,为保护隐私,更改了一些个人详细信息: // Configure require_once('sdks/Amazon/.config.inc.php'); $serviceUrl = "https://mws.amazonservices.com/MerchantFulfillment/2015-06-01"; $config = array( 'ServiceURL' => $serviceUrl, 'P
// Configure
require_once('sdks/Amazon/.config.inc.php');
$serviceUrl = "https://mws.amazonservices.com/MerchantFulfillment/2015-06-01";
$config = array(
'ServiceURL' => $serviceUrl,
'ProxyHost' => null,
'ProxyPort' => -1,
'ProxyUsername' => null,
'ProxyPassword' => null,
'MaxErrorRetry' => 3
);
// Create service
$merchant_service = new Amazon_Merchant_Client(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, APPLICATION_NAME, APPLICATION_VERSION, $config);
// Create request object
$request = new Amazon_Merchant_Model_CreateShipmentRequest();
// Set SellerId
$request->setSellerId(MERCHANT_ID);
// Define shipping info
$package_dimensions = array(
'Length' => 5,
'Width' => 5,
'Height' => 5,
'Unit' => 'inches',
);
$weight = array(
'Value' => 5,
'Unit' => 'ounces',
);
$ship_from_address = array(
'Name' => '904Custom',
'AddressLine1' => 'foobar',
'AddressLine2' => 'foobar',
'Email' => 'foobar@foobar.com',
'City' => 'foobar',
'StateOrProvinceCode' => 'FL',
'PostalCode' => '12345',
'CountryCode' => 'US',
'Phone' => '(888) 555-5555',
);
$shipping_service_options = array(
'DeliveryExperience' => 'DeliveryConfirmationWithoutSignature',
'CarrierWillPickUp' => true,
);
$shipping_details_array = array(
'AmazonOrderId' => '114-1234567-1234567',
'SellerOrderId' => '114-1234567-1234567',
'ShipFromAddress' => $ship_from_address,
'PackageDimensions' => $package_dimensions,
'Weight' => $weight,
'ShippingServiceOptions' => $shipping_service_options,
);
$request->setShipmentRequestDetails($shipping_details_array);
// Set shipping service id
$request->setShippingServiceId('1234');
// Invoke request
// invokeCreateShipment is a wrapper for $service->CreateShipment($request);
$result = $this->invokeCreatehipment($merchant_service, $request);
这给了我
致命错误:对第276行/var/www/hydra/sdks/Amazon/Merchant/Model.php中的非对象调用成员函数_toQueryParameterArray()
细节可能不正确,但现在我只是尝试向API发送一个请求,SDK不允许我这样做,因为它遇到了致命的PHP错误。为了让它更有价值,我删除了$request->setShipmentRequestDetails(),看看我会得到什么结果。我确实收到了API的响应,但这是一个内部失败XML:
<ErrorResponse xmlns="https://mws.amazonservices.com/MerchantFulfillment/2015-06-01">
<Error>
<Type>Receiver</Type>
<Code>InternalFailure</Code>
</Error>
<RequestId>b1f5a04c-54ac-442c-ab88-f2f1c9374377</RequestId>
</ErrorResponse>
我已经阅读了以下所有文档
我已经查看了SDK中包含的示例文件,但它们不是完整的示例
我已经在谷歌上做了详尽的搜索,但是在野外找不到这个SDK的任何用法
我尝试在源代码中使用var_dump()来找出发生了什么,但它非常抽象,很难使用。例如,toQueryParameterArray()
调用\u-toQueryParameterArray()
调用\u-toQueryParameterArray()
调用\u-toQueryParameterArray()
和\u-toQueryParameterArray()
。代码很难理解,编写解决方案的尝试也失败了
这里是官方亚马逊MWS商户实现API PHP SDK的镜像,仅供参考
多年来,我一直以多种方式使用Orders、Feed和Reports API,但在Merchant API上,我遇到了难题,需要一些帮助
我如何使用Amazon MWS商户履行API PHP SDK购买航运服务?多亏了Bullcom,我找到了答案 我需要创建对象并使用setter和getter,而不仅仅是传递数据数组 所以我的新代码看起来更像这样
$shipping_details = new Amazon_Merchant_Model_ShipmentRequestDetails();
$weight = new Amazon_Merchant_Model_Weight();
$weight->setValue(5);
$weight->setUnit('ounces');
$shipping_details->setWeight($weight);
这肯定应该在SDK的示例文件夹中,而不是含糊其辞地说他们当前有“//object”或参数数组“我确认您是否需要为每个必需的参数构建一个对象。除了需要是MWSMerchantFulfillmentService\u Model\u项目对象数组的ItemList之外