2012-07-22 83 views
7

下載解壓縮亞馬遜的MWS client library api後,我試圖運行其中一個腳本來查看是否一切正常。亞馬遜mws api類'MarketplaceWebService_Client'未找到錯誤

試圖運行該文件GetReportCountSample.php我得到的錯誤,當

Fatal error: Class 'MarketplaceWebService_Client' not found in C:\xampp\htdocs\sites\amazon marketplace\Samples\GetReportCountSample.php on line 68 

我已經通過配置文件看,我有我的輸入憑證,例如:

define('AWS_ACCESS_KEY_ID', '<key id>');     //has been input 
define('AWS_SECRET_ACCESS_KEY', '<secret key id>');  //has been input 

define('APPLICATION_NAME', '<Your Application Name>'); //no idea what this is 
define('APPLICATION_VERSION', '<Your Application Version or Build Number>'); //no idea 

define ('MERCHANT_ID', '<merch id>');     //has been input 

我可以沒有找到一個名爲MarketplaceWebService_Client的PHP文件,我需要幫助,謝謝。

+0

我遇到了同樣的問題。我認爲它與'set_include_path(get_include_path()。PATH_SEPARATOR。'../../'')有關;'如果我弄清楚了,我會發佈一個答案。 – 2012-09-06 22:58:32

+0

@VitaliyIsikov嘿維生素,我已經放棄了無用的zip文件,並使用XML創建更簡單的功能。謝謝 – 2012-09-06 23:24:35

回答

4

沒有名爲MarketplaceWebService_Client的php文件。它的Client.php在您下載的庫中。 MarketplaceWebService_Client類僅在client.php文件中。我認爲包含路徑Client.php在GetReportCountSample.php中沒有正確指定。 Client.php可在以下路徑(外的試樣的文件夾):C:\ XAMPP \ htdocs中\網站\亞馬遜的市場\ Client.php

+0

嗨,這是什麼APPLICATION_VERSION-開發人員帳號? – 2016-03-29 17:11:01

1

我意識到這是一個老問題,但我有一個類似的問題,並認爲我會分享我的發現。

由於您已更改庫安裝路徑,因此出現此問題。

... not found in C:\xampp\htdocs\sites\amazon marketplace\Samples\GetReportCountSample.php 

通過不包括Lib目錄它已經產生了這個錯誤。如果通過.config.php閱讀你會看到

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

這意味着你需要有正確的路徑一旦類已經被拆分與下劃線。通過它,它正在尋找路徑「MarketplaceWebService/client.php」。通過刪除「MarketplaceWebService」目錄,它將無法找到該文件來定義類。

要解決問題,只需將庫安裝到「htdocs \ sites \ amazon marketplace \ MarketplaceWebService \」,一切都會好的。

希望這可以幫助別人。

2

裏面.config.inc.php您將有以下幾點:

/************************************************************************ 
    * OPTIONAL ON SOME INSTALLATIONS 
    * 
    * Set include path to root of library, relative to Samples directory. 
    * Only needed when running library from local directory. 
    * If library is installed in PHP include path, this is not needed 
    ***********************************************************************/ 
    set_include_path(get_include_path() . PATH_SEPARATOR . '../../.'); 

這個定義包含路徑,這是在這個程序中加載所有的類配套文件。每一個都由PATH_SEPARATOR分隔。該函數添加另一個包含路徑,該路徑是當前工作目錄上方的2個目錄,並且不是正確的目錄。你必須指向src目錄。

要解決此問題,請將'../../.'更改爲指向src文件夾所在的目錄。我的腳本和src目錄位於同一父目錄中,所以我的代碼如下所示:

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