I have the code
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);
}
But instead of returning the user object like stated in the docs, I get shown a 'response' object instead.
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"
}
Anyway to obtain the user object? I am using php 5.4 with Guzzle 5.3, and laravel 5.0.
Edit: I tried using the getBody() method as well as getBody->getContents() method but it doesn't work, getBody will just show the streams part of the response, getContents will give a weird HTML file.
JSON_DECODE doesn't work as well, it returns error code 4 which is JSON_ERROR_SYNTAX. Is the response supposed to be a JSON form?