응답 메타데이터

PHP 클라이언트 라이브러리는 기본적으로 요청 ID를 포함하여 응답 메타데이터를 로그합니다. 또는 선택적 매개변수 withResponseMetadatatrue로 설정하여 클라이언트 서비스 메서드를 호출할 때 프로그래매틱 방식으로 응답 메타데이터를 가져올 수 있습니다.

다음은 쿼리를 GoogleAdsService.SearchStream()에 전송하고 withResponseMetadatatrue로 설정하는 예입니다.

[$response, $metadata] = $googleAdsServiceClient->searchStream(
    $customerId,
    $query,
    ['withResponseMetadata' => true]
);

SearchGoogleAdsStreamResponse의 쿼리 결과로 구성된 $response와 함께 배열이 반환됩니다.

배열의 두 번째 멤버 $metadata는 그 자체가 배열인 metadata 필드에 응답 메타데이터를 보유합니다.

object(Google\Ads\GoogleAds\Lib\V16\GoogleAdsResponseMetadata)#51 (1) {
  ["metadata":"Google\Ads\GoogleAds\Lib\V16\GoogleAdsResponseMetadata":private]=>
  array(17) {
    ["content-disposition"]=>
    array(1) {
      [0]=>
      string(10) "attachment"
    }
    ["request-id"]=>
    array(1) {
      [0]=>
      string(22) "REQUEST_ID"
    }
    ...
  }
}

GoogleAdsResponseMetadata::getRequestId()를 사용하는 방법과 유사하게 request-id 키에서 요청 ID를 검색할 수 있습니다.