Closed ehtasham-geode closed 7 years ago
I have found the solution of this error, Brief detail about this is as
The 404 crashing errors faced while integrating ticketevolution library with your system was due to following reasons.
1) SSL verfication by default set to true in library. 2) Library crashing while invalid id's or data not found case.
For ssl Error fixation what you need to do is while connecting to this library add an option 'SSLVerification' => false in settings method
$tickets = new TicketEvolution(); $apiClient = $tickets->settings([ 'baseUrl' => 'http://api.ticketevolution.com', 'apiVersion' => 'v9', 'apiToken' => 'your_token', 'apiSecret' => 'your_secret', 'SSLVerification' => false ]);
Now in the vendor\ticketevolution\ticketevolution-php\src\Client.php file buildClient method add
if (isset( $this->_settings['SSLVerification']) && $this->_settings['SSLVerification']==false) $client->setDefaultOption('verify', false);
It will set the SSL verification false and will not crash in SSL verification case.
private function buildClient()
{
$client = $this->getBaseClient();
if (isset( $this->_settings['SSLVerification']) && $this->_settings['SSLVerification']==false)
$client->setDefaultOption('verify', false);
if (!static::$_description) {
$this->reloadDescription();
}
$this->_client = new GuzzleClient(
$client,
static::$_description,
[
'emitter' => $this->_baseClient->getEmitter(),
]
);
}
For data not found or invalid id case fixation at the end of __cal method of vendor\ticketevolution\ticketevolution-php\src\Client.php file
try { $response = call_user_func_array([$this->_client, $method], $parameters); return $response; } catch (\Exception $e) { return ["ServerError" => $e->getMessage()]; }
In case of exception it will not crash and send you the exception message like id not found/invalid id.
You just need to check while accessing any method in application if [ServerError] is set in the response, if yes show that to user as output response.
Until the above mentioned steps are not added in the library this is the solution you can use to manually fix the errors you are facing
exception 'GuzzleHttp\Exception\ClientException' with message 'Client error response [url] https://api.ticketevolution.com/v9/events/search?occurs_at.gt=2017-11-30T18%3A00%3A00Z&occurs_at.lt=2017-11-30T20%3A00%3A00Z&page=1&per_page=100&q=Come+From+Away [status code] 404 [reason phrase] Not Found' in /var/www/vhosts/mydomain.com/httpdocs/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:89