eveseat / eseye

👾 A Standalone, Dynamic ESI (EVE Swagger Interface) Client Library written in PHP
GNU General Public License v2.0
50 stars 30 forks source link

Search Endpoint #39

Closed drkthunder02 closed 5 years ago

drkthunder02 commented 6 years ago

Having some issues using the search end point which is public. I have listed the search and categories as an array, but the fetcher doesn't seem to want to grab it from the array. Could use some help. Error is listed below with the programming code.

PHP Fatal error: Uncaught Seat\Eseye\Exceptions\RequestFailedException: 'categories' is required, 'search' is required in /var/www/dokureg/vendor/eveseat/eseye/src/Fetchers/GuzzleFetcher.php:242 Stack trace:

0 /var/www/dokureg/vendor/eveseat/eseye/src/Fetchers/GuzzleFetcher.php(102): Seat\Eseye\Fetchers\GuzzleFetcher->httpRequest('get', 'https://esi.eve...', Array, NULL)

1 /var/www/dokureg/vendor/eveseat/eseye/src/Eseye.php(448): Seat\Eseye\Fetchers\GuzzleFetcher->call('get', 'https://esi.eve...', Array)

2 /var/www/dokureg/vendor/eveseat/eseye/src/Eseye.php(256): Seat\Eseye\Eseye->rawFetch('get', 'https://esi.eve...', Array)

3 /var/www/dokureg/cron/cleanup.php(50): Seat\Eseye\Eseye->invoke('get', Object(GuzzleHttp\Psr7\Uri), Array)

4 {main}

thrown in /var/www/dokureg/vendor/eveseat/eseye/src/Fetchers/GuzzleFetcher.php on line 242

//Set the configuration parameters $configuration = \Seat\Eseye\Configuration::getInstance(); $configuration->logfile_location = '/var/www/dokureg/logs'; $configuration->file_cache_location = '/var/www/dokureg/cache';

//Make a new eseye object $esi = new \Seat\Eseye\Eseye(); //Open the database connection $db = DBOpen(); //Get the users from the database $users = $db->fetchRowMany('SELECT * FROM user');

//Cycle through each user in the database and decide whether to delete them or not. foreach($users as $user) { //Form the name of the character from the username. $name = strreplace('', ' ', $user['name']); $characterId = $esi->invoke('get', '/search/', [ 'categories' => 'character', 'language' => 'en-us', 'search' => $name, 'strict' => 'false' ]); var_dump($characterId); die();

drkthunder02 commented 6 years ago

From the logs:

[2018-08-24 22:04:04] eseye.ERROR: [http 400, bad request] get -> https://esi.evetech.net/latest/search/?datasource=tranquility [t/e: 0.08s/99]

Doesn't seem like I am building the url correctly.

paulipa commented 5 years ago

Wonderhing the same myself, trying to pull IDs based on usernames

include 'vendor/autoload.php';

$esi = new \Seat\Eseye\Eseye(new \Seat\Eseye\Containers\EsiAuthentication([
    'client_id'     => 'x',
    'secret'        => 'x',
    'refresh_token' => 'zx',
]));

$character_info = $esi->invoke('get', '/search/', [
    'categories' => 'character',
    'language' => 'en-us',
    'search' => 'Ikarus Cesaille',
    'strict' => 'false'
]);

var_dump($character_info);

results in

PHP Fatal error:  Uncaught Seat\Eseye\Exceptions\RequestFailedException: 'categories' is required, 'search' is required in /var/www/html/vendor/eveseat/eseye/src/Fetchers/GuzzleFetcher.php:228
warlof commented 5 years ago

the third parameter of invoke is only accepting route path encoded parameter. You need to use setQueryString() prior calling invoke with the desired query parameters.

Be gentle with search endpoint and prefer /universe/names/ and /universe/ids/ instead. https://developers.eveonline.com/blog/article/the-esi-api-is-a-shared-resource-do-not-abuse-it