Только 7 дней: Скидка 20% на три стильных букета из нашей летней коллекции!';
- $pic1Path = curl_file_create(
- __DIR__ . '/../web/images/pic_1.jpg',
- 'image/jpg',
- 'pic_1.jpg'
- );
+ $pic1Path =__DIR__ . '/../web/images/pic_1.jpg';
- $pic2Path = curl_file_create(
- __DIR__ . '/../web/images/pic_2.jpg',
- 'image/jpg',
- 'pic_2.jpg'
- );
+ $pic2Path = __DIR__ . '/../web/images/pic_2.jpg';
- $pic3Path = curl_file_create(
- __DIR__ . '/../web/images/pic_3.jpg',
- 'image/jpg',
- 'pic_3.jpg'
- );
+ $pic3Path = __DIR__ . '/../web/images/pic_3.jpg';
$result = 'false';
$buttons = self::getTgShortButtons($chatId);
$client = new Client();
+
+ $media = [
+ [
+ 'type' => 'photo',
+ 'media' => 'attach://pic_1.jpg',
+ 'caption' => $text,
+ ],
+ [
+ 'type' => 'photo',
+ 'media' => 'attach://pic_2.jpg',
+ ],
+ [
+ 'type' => 'photo',
+ 'media' => 'attach://pic_3.jpg',
+ ]
+ ];
+
try {
- $response1 = $client->post($apiURL1, [
- 'json' => [
- 'chat_id' => $chatId,
- 'media' => json_encode([
- ['type' => 'photo', 'media' => 'attach://pic_1.jpg', "caption" => $text],
- ['type' => 'photo', 'media' => 'attach://pic_2.jpg' ],
- ['type' => 'photo', 'media' => 'attach://pic_3.jpg' ],
- ]),
- 'pic_1.jpg' => $pic1Path,
- 'pic_2.jpg' => $pic2Path,
- 'pic_3.jpg' => $pic3Path,
- ],
+ $response1 = $client->post($apiURL1,[
+ 'multipart' => [
+ [
+ 'name' => 'chat_id',
+ 'contents' => $chatId
+ ],
+ [
+ 'name' => 'media',
+ 'contents' => json_encode($media)
+ ],
+ [
+ 'name' => 'pic_1.jpg',
+ 'contents' => fopen($pic1Path, 'r')
+ ],
+ [
+ 'name' => 'pic_2.jpg',
+ 'contents' => fopen($pic2Path, 'r')
+ ],
+ [
+ 'name' => 'pic_3.jpg',
+ 'contents' => fopen($pic3Path, 'r')
+ ],
+ ]
]);
if ($response1->getStatusCode() !== 200) {