Amazon mws api Class 'MarketplaceWebService_Client' not found error
Asked Answered
E

3

7

After downloading an unzipping Amazon's MWS client library api I have tried to run one of the scripts to see if everything is working.

when trying to run the file GetReportCountSample.php I get the error

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

I've looked through the config file and I have input my credentials such as:

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

I can not find a php file called MarketplaceWebService_Client, I need help, thanks.

Esp answered 22/7, 2012 at 12:49 Comment(2)
I'm having this same issue. I'm thinking it has something to do with set_include_path(get_include_path() . PATH_SEPARATOR . '../../.'); I will post an answer if I figure this out.Kidder
@VitaliyIsikov Hey Vit, I have Abandoned there useless zip files and have created simpler functions using xml. thanks anywayEsp
D
4

There is no php file called MarketplaceWebService_Client. Its Client.php in your downloaded library. MarketplaceWebService_Client Class is in client.php file only. I think include path of Client.php is not correctly specified in GetReportCountSample.php. Client.php may be in the following path(Outside of Samples folder): C:\xampp\htdocs\sites\amazon marketplace\Client.php

Deformation answered 23/1, 2013 at 10:0 Comment(1)
Hi, what is APPLICATION_VERSION here- Developer Account Number?Sixtynine
S
2

Inside .config.inc.php you will have the following:

   /************************************************************************
    * 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 . '../../.');

This defines include paths, which are used in this program to load all the assorted files for the classes. Each one is seperated by PATH_SEPARATOR. This function adds another include path, which is 2 directories above the current working directory, and that is not the right directory. You have to point to the src directory.

To fix this, change '../../.' to point to the directory where the src folder is. My scripts and the src directory are in the same parent directory, so my code looks like this:

set_include_path(get_include_path() . PATH_SEPARATOR . getcwd().'/src/');
Scorekeeper answered 22/1, 2015 at 23:48 Comment(0)
T
1

I realise this is an old question but I had a similar problem and thought I'd share my findings.

The problem here has occurred because you have altered your library install path.

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

By not including the Lib directory it has generated this error. If you read through the .config.php you'll see

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

This means that you need to have the path correct once the class has been split with the underscore. By that it is looking for the path "MarketplaceWebService/client.php". By removing the directory "MarketplaceWebService" it will fail to find this file to define the class.

To rectify simply install your library to "htdocs\sites\amazon marketplace\MarketplaceWebService\" and all should be well.

Hope this helps someone.

Tentage answered 7/11, 2014 at 13:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.