狂饮电报Bot API - '方法不显示用户对象


Guzzle with telegram Bot API - 'GetMe' method not displaying a user object

我有代码

public function getClient(){
 $token = getenv('TELEGRAM_TOKEN');
 $uri = 'https://api.telegram.org/bot'.$token.'/';
 $client = new Client(['base_url' => $uri]);
 return $client;
}
public function getMyBot(){
 $client = $this->getClient();
 $response = $client->get( '/getMe' );
 dd($response);
}

但是没有像文档中描述的那样返回user对象,而是显示了一个'response'对象。

Response {#188 ▼
  -reasonPhrase: "OK"
  -statusCode: 200
  -effectiveUrl: "https://core.telegram.org/bots"
  -headers: array:9 [▼
    "server" => array:1 [▶]
    "date" => array:1 [▶]
    "content-type" => array:1 [▶]
    "content-length" => array:1 [▶]
    "connection" => array:1 [▶]
    "pragma" => array:1 [▶]
    "cache-control" => array:1 [▶]
    "x-frame-options" => array:1 [▶]
    "strict-transport-security" => array:1 [▶]
  ]
  -headerNames: array:9 [▼
    "server" => "Server"
    "date" => "Date"
    "content-type" => "Content-Type"
    "content-length" => "Content-Length"
    "connection" => "Connection"
    "pragma" => "Pragma"
    "cache-control" => "Cache-control"
    "x-frame-options" => "X-Frame-Options"
    "strict-transport-security" => "Strict-Transport-Security"
  ]
  -body: Stream {#189 ▼
    -stream: :stream {@280 ▶}
    -size: null
    -seekable: true
    -readable: true
    -writable: true
    -uri: "php://temp"
    -customMetadata: []
  }
  -protocolVersion: "1.1"
}

如何获取用户对象?我使用php 5.4与Guzzle 5.3,和laravel 5.0。

编辑:我尝试使用getBody()方法以及getBody->getContents()方法,但它不起作用,getBody将只显示响应的流部分,getContents将给出一个奇怪的HTML文件。

JSON_DECODE不工作,它返回错误代码4,这是JSON_ERROR_SYNTAX。响应应该是JSON表单吗?

需要显示body的内容。

dd($response->getBody()->getContents())

顺便说一下,您可以使用非官方的laravel现成SDK,它也可以与Guzzle一起使用。