亚马逊MWS致命错误

时间:2015-05-21 10:19:11

标签: php api amazon-web-services amazon

我正在尝试从亚马逊中提取/下载商家信息到我最近创建的网站。问题是我目前正在收到致命错误

Fatal error: Class 'MarketplaceWebServiceProducts_Client' not found in /var/www/html/hello/src/MarketplaceWebServiceProducts/Samples/ListMatchingProductsSample.php on line 53

我正在经历这个困难时期。这是我的代码:

require_once('config.inc.php');

$serviceUrl = "https://mws.amazonservices.com/Products/2011-10-01";


 $config = array (
   'ServiceURL' => $serviceUrl,
   'ProxyHost' => null,
   'ProxyPort' => -1,
   'ProxyUsername' => null,
   'ProxyPassword' => null,
   'MaxErrorRetry' => 3,
 );

$service = new MarketplaceWebServiceProducts_Client(
    AWS_ACCESS_KEY_ID,
    AWS_SECRET_ACCESS_KEY,
    APPLICATION_NAME,
    APPLICATION_VERSION,
    MERCHANT_ID,
    MARKETPLACE_ID
);

 $request = new MarketplaceWebServiceProducts_Model_ListMatchingProductsRequest();
 $request->setSellerId(A3O22V420SDTFY);
 invokeListMatchingProducts($service, $request);

  function invokeListMatchingProducts(MarketplaceWebServiceProducts_Interface $service, $request)
  {
  try {
    $response = $service->ListMatchingProducts($request);

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

    $dom = new DOMDocument();
    $dom->loadXML($response->toXML());
    $dom->preserveWhiteSpace = false;
    $dom->formatOutput = true;
    echo $dom->saveXML();
    echo("ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");

 } catch (MarketplaceWebServiceProducts_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");
 }
 }

这是我在config.inc.php中的代码:

define('AWS_ACCESS_KEY_ID', 'TYPE_YOUR_CREDENTIALS_HERE');
define('AWS_SECRET_ACCESS_KEY', 'TYPE_YOUR_CREDENTIALS_HERE');
define('APPLICATION_NAME', 'TYPE_YOUR_CREDENTIALS_HERE');
define('APPLICATION_VERSION', 'TYPE_YOUR_CREDENTIALS_HERE');
define ('MERCHANT_ID', 'TYPE_YOUR_CREDENTIALS_HERE');
define ('MARKETPLACE_ID', 'TYPE_YOUR_CREDENTIALS_HERE');

set_include_path(get_include_path() . PATH_SEPARATOR . '../../.');

 function __autoload($className){
    $filePath = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
    $includePaths = explode(PATH_SEPARATOR, get_include_path());
    foreach($includePaths as $includePath){
        if(file_exists($includePath . DIRECTORY_SEPARATOR . $filePath)){
            require_once $filePath;
            return;
        }
    }
}

0 个答案:

没有答案