Try this as a multi-page post.
$client->post(
'https://api.telegram.org/botMyApiKey/sendPhoto',
array(
'multipart' => array(
array(
'name' => 'chat_id',
'contents' => '1111111'
),
array(
'name' => 'photo',
'contents' => $contents
)
)
)
);
Gtzz documentation link
For Guzzle 5.3
use GuzzleHttp\Client;
$client = new Client(['defaults' => [
'verify' => false
]]);
$response = $client->post('https://api.telegram.org/bot[token]/sendPhoto', [
'body' => [
'chat_id' => 'xxxxx',
'photo' => fopen(__DIR__ . '/test.jpg', 'r')
]
]);
var_dump($response);
Note: you must pass the file descriptor to the photo attribute, not the contents of the file.
source
share