php - Call to undefined method GuzzleHttp\Psr7\Response::isSuccessful() -
so have installed guzzle library version 6 according teamup calendar documentation. however, when try run code below
fatal error: call undefined method guzzlehttp\psr7\response::issuccessful()
code:
<?php include 'vendor/autoload.php'; define('api_key','****ww9d5ea2b0540ba1e02c08100b0e5**'); $client = new guzzlehttp\client(['headers' => ['teamup-token' => api_key]]); $res = $client->get('https://api.teamup.com/ks************/events?startdate=2016-08-21&enddate=2016-08-25'); if ($res->issuccessful()) { echo $res->getbody(); // {"event":{ ... }} }
shouldn't contained in library? anyone?
yes, there no method issuccessful
. default guzzle throw exception if server return error
http://docs.guzzlephp.org/en/latest/quickstart.html
a guzzlehttp\exception\serverexception thrown 500 level errors if http_errors request option set true.
a guzzlehttp\exception\clientexception thrown 400 level errors if http_errors request option set true.
in event of networking error (connection timeout, dns errors, etc.), guzzlehttp\exception\requestexception thrown.
anyway, can check status code of response using
$res->getstatuscode();
Comments
Post a Comment