2016-08-24 2 views
2

그래서 Guzzle 라이브러리 버전 6을 TeamUp calendar documentation에 따라 설치했습니다. 내가 코드를 실행하려고 할 때, 내가 얻을 아래정의되지 않은 메서드 호출 GuzzleHttp Psr7 Response :: isSuccessful()

Fatal error: Call to undefined method GuzzleHttp\Psr7\Response::isSuccessful() 

코드 :

이 라이브러리에 포함되지 않도록한다

<?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":{ ... }} 
} 
? 누구?

답변

1

예, 방법이 없습니다 isSuccessful. http_errors 옵션을 true로 설정 요청하면 서버 반환 오류

http://docs.guzzlephp.org/en/latest/quickstart.html

GuzzleHttp \ 예외 \의 ServerException 500 수준 오류 에 대해 발생하는 경우 기본 목구멍으로 는 예외가 발생합니다.

http_errors 요청 옵션이 true로 설정된 경우 GuzzleHttp \ Exception \ ClientException이 400 레벨 오류 에 대해 발생합니다.

네트워크 오류 (연결 시간 제한, DNS 오류, 등)가 발생하면 GuzzleHttp \ Exception \ RequestException이 발생합니다.

어쨌든,

$res->getStatusCode(); 
0

upgrade notes from Guzzle 5.0 to Guzzle 6.0 say 사용하여 응답의 상태 코드를 확인할 수 있습니다

GuzzleHttp \ 메시지 \ 응답 : isSuccessful() 및 기타 관련 방법 것이왔다 제거되었습니다. 대신에 getStatusCode()를 사용하십시오.

관련 문제