davidtsadler / ebay-sdk-php

An eBay SDK for PHP. Use the eBay API in your PHP projects.
Apache License 2.0
349 stars 341 forks source link

Unknown configuration option: DTS\\eBaySDK\\Finding\\Services\\FindingService::credentials #56

Closed dominic-ks closed 7 years ago

dominic-ks commented 7 years ago

I'm having issues running anything using the SDK that requires use of credentials. I have been able to use your basic example if getting the eBay time just fine, however, when attempting to use one of the examples, e.g. 01-basic-keywords-search.php, I am getting the following:

mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'DTS\\eBaySDK\\Exceptions\\UnknownConfigurationOptionException' with message 'Unknown configuration option: DTS\\eBaySDK\\Finding\\Services\\FindingService::credentials' in /path-to-my-project/vendor/dts/ebay-sdk-php/src/DTS/eBaySDK/Services/BaseService.php:343

I have attempted to use a configuration.php file in the format provided in the examples as well as hard coding the app id, dev id and cert id.

Are you able to shed any light on what the issue may be here?

davidtsadler commented 7 years ago

If you are using the examples first ensure that you have the most up to date version of both the examples and the SDK. If that doesn't work I will need to see the code that is failing.

dominic-ks commented 7 years ago

Thanks David,

I installed the SDK today according to the instructions here - https://github.com/davidtsadler/ebay-sdk-php/blob/master/README.md - i.e. just by running

$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require dts/ebay-sdk-php

I haven't downloaded the examples all together, I just copied the code from here - https://github.com/davidtsadler/ebay-sdk-examples/blob/master/finding/01-simple-keywords-search.php

I'm just trying to run this code, the autoload.php file is being found and no issues there. So I tried:

  1. Including a configuration .php file with the code below and tried running the example file as is (but from the root of my project):
<?php

return [
    'sandbox' => [
        'credentials' => [
          'devId'  => 'MY_DEV ID',
          'appId'  => 'MY_SB_APP_ID',
          'certId' => 'MY_SB_CERT_ID',
        ],
        'authToken' => 'AUTH_TOKEN'
    ],
    'production' => [
        'credentials' => [
          'devId'  => 'MY_DEV ID',
          'appId'  => 'MY_PROD_APP_ID',
          'certId' => 'MY_PROD_CERT_ID',
        ],
        'authToken' => 'AUTH_TOKEN'
    ]
];
  1. I also tried commenting out line 27, i.e.

// $config = require __DIR__.'/../configuration.php';

And then edited from line 35 to hard code my credentials like so:

/**
 * Create the service object.
 */
$service = new Services\FindingService([
    'credentials' => [
          'devId'  => 'MY_DEV ID',
          'appId'  => 'MY_PROD_APP_ID',
          'certId' => 'MY_PROD_CERT_ID',
    ],
    'globalId'    => Constants\GlobalIds::US,
]);

Both of these produced the same error and I am unable to understand why.

davidtsadler commented 7 years ago

The code is OK but it does look like you are using a very old version of the SDK. It used to throw an UnknownConfigurationOptionException exception when you tried to set a configuration option that didn't exist. That feature was removed.

There are a few things that you can do to see what version of the SDK you have installed.

dominic-ks commented 7 years ago

Right OK, found the problem - for some reason the CLI on my server was using PHP 5.4.45 rather than 5.6 which is running on the web server, so I assume that composer automatically downloaded the most up to date version I could use, which was, ehem, v0.6...

Forced it to use php5.5 and that's allowed me to download v7 of the SDK and looks like I'm up and running.

Thanks for your time on this. There's a good few hours I'll never see again, but lesson learned.

davidtsadler commented 7 years ago

No problem :)

MartinSieben commented 7 years ago

Hello Davidt

it took me some time to get to this thread because i faced the same problem. so i think its because of the installed version. composer gave me and outdated version:

Using version ^0.6.0 for dts/ebay-sdk-php ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 4 installs, 0 updates, 0 removals

i use php 7.0.12 on a 2 month old server and tried as fastcgi as well as fpm. Does your tool support php 7 or shall i install another version or what depencies are important?

davidtsadler commented 7 years ago

Php 7 is supported by the SDK. Ensure that you install a version of the SDK that is 1.0.0 or greater as it looks like you are installing an old version.

MartinSieben commented 7 years ago

Thanks for the fast answer. working with the following (as recommended in the manual) curl -sS https://getcomposer.org/installer | php php composer.phar require dts/ebay-sdk-php installs an old version.

so i switched to working with the phar-file (uploading to the webspace and require it within the script by the following line require 'ebay-sdk-php.phar';

maybe this helps others facing the same problem with composer.

dominic-ks commented 7 years ago

MartinSieben,

Did you check the solution that I had found above?

Depending on your server set up and config, when using the CLI you may be using a different php version than the web server vhost you're using to run you site or app.

MartinSieben commented 7 years ago

Hi dominic

i haven't checked it because i'm not firm with that and dunno where to look for that. i have an up2date-server running plesk and composer gives me version 0.6.0 so that its obvious that it gets wrong parameters. fortunately i got it running with that phar but if you need for troubleshouting-reasons my php-info i could mail it to you.

also i used examples to get orders from ebay but with that recommended code i got empty request--objects

here's the output for ... ... $request = new Types\GetJobsRequest(); print_r($request);

is the following DTS\eBaySDK\BulkDataExchange\Types\GetJobsRequest Object ( [values:DTS\eBaySDK\Types\BaseType:private] => Array ( ) [attachment:DTS\eBaySDK\Types\BaseType:private] => Array ( [data] => [mimeType] => ) )

the configuration in $service is not needed at this point, even if i filled in the right data and checked if they are available in the script.

also in the code-example (ebay-sdk-examples/large-merchant-services/01-get-jobs.php) you wrote

$service = new Services\BulkDataExchangeService([ 'credentials' => $config['production']['credentials'], 'authToken' => $config['sandbox']['authToken'], 'sandbox' => true ]);

and mixed sandbox and production which should be fixed. could it be that there are also some variables missing?