정의되지 않은 메서드 GuzzleHttp\Command\Result::getBody() 호출 중
<p>Drupal의 외부 API로부터 json 형식의 응답을 얻으려고 합니다. 저는 HTTP 클라이언트 관리자 Drupal 모듈을 사용하고 있습니다.
이제 배열에서는 stdClass 객체 형식의 응답만 얻을 수 있고 모든 응답 키 값은 손실됩니다. </p>
<p>내 원래 코드: </p>
<pre class="brush:php;toolbar:false;">공용 함수 findPosts() {
$client = $this->getClient();
$params = array('client_Id' => "12345",
"클라이언트_비밀" => "42452454",
"범위" => "읽기");
$response = $client->FindPosts($params);
dpm($응답);
반환 ['#markup' =>
}</pre>
<p>다음 코드를 출력하세요. 또한 [access_token] => eyJhbGciOiJIUzUxMiIsIn, [type] => bearer 등처럼 보이도록 해야 합니다. </p>
<pre class="brush:php;toolbar:false;">stdClass 객체
(
[__CLASS__] => GuzzleHttpCommandResult
[데이터:보호됨] => 배열
(
[0] =>eyJhbGciOiJIUzUxMiIsIn
[1] =>
[2] => 3600
[3] => 2022-11-09T10:48:47+00:00
[4] => 읽다
[5] => MwA1ADkAZAA0AGIAZAA4AC0AOQAzADcA
[6] => 86400
[7] => 2022-11-10T09:48:47+00:00
)
)</pre>
<p>$response->getBody(), $response->getContent() 또는 기타 응답 메서드를 시도하면 다음 오류가 반환됩니다.</p>
<pre class="brush:php;toolbar:false;">오류: Drupalhttp_client_manager_exampleControllerExampleController->findPosts()에서 정의되지 않은 메서드 GuzzleHttpCommandResult::getBody() 호출(modules/contrib/http_client_manager/modules/http_client_manager_example의 92번째 줄) /src/Controller/ExampleController.php).
Drupalhttp_client_manager_exampleControllerExampleController->findPosts()
call_user_func_array(Array, Array) (라인: 123)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->DrupalCoreEventSubscriber{closure}() (라인: 564)
DrupalCoreRenderRenderer->executeInRenderContext(Object, Object) (라인: 124)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (라인: 97)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->DrupalCoreEventSubscriber{closure}() (라인: 169)
SymfonyComponentHttpKernelHttpKernel->handleRaw(Object, 1) (라인: 81)
SymfonyComponentHttpKernelHttpKernel->handle(Object, 1, 1) (라인: 58)
DrupalCoreStackMiddlewareSession->handle(Object, 1, 1) (라인: 48)
DrupalCoreStackMiddlewareKernelPreHandle->handle(Object, 1, 1) (라인: 106)
Drupalpage_cacheStackMiddlewarePageCache->pass(Object, 1, 1) (라인: 85)
Drupalpage_cacheStackMiddlewarePageCache->handle(Object, 1, 1) (라인: 49)
Asm89StackCors->handle(Object, 1, 1) (라인: 48)
DrupalCoreStackMiddlewareReverseProxyMiddleware->handle(Object, 1, 1) (라인: 38)
DrupalwebprofilerStackMiddlewareWebprofilerMiddleware->handle(Object, 1, 1) (라인: 51)
DrupalCoreStackMiddlewareNegotiationMiddleware->handle(Object, 1, 1) (라인: 23)
StackStackedHttpKernel->handle(Object, 1, 1) (라인: 709)
DrupalCoreDrupalKernel->handle(Object) (라인: 19)