Skip to content

Commit 450d9a6

Browse files
committed
Convert all data object fields to JSON strings.
1 parent f55fd1c commit 450d9a6

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Request.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,16 @@ private static function setUpRequestParams(array $data)
371371
if (is_string($item) && file_exists($item)) {
372372
$item = new Stream(self::encodeFile($item));
373373
}
374-
} elseif (is_array($item)) {
375-
// Convert any nested arrays into JSON strings.
374+
} elseif (is_array($item) || is_object($item)) {
375+
// Convert any nested arrays or objects into JSON strings.
376376
$item = json_encode($item);
377377
}
378378

379379
// Reformat data array in multipart way if it contains a resource
380380
$has_resource = $has_resource || is_resource($item) || $item instanceof Stream;
381381
$multipart[] = ['name' => $key, 'contents' => $item];
382382
}
383+
unset($item);
383384

384385
if ($has_resource) {
385386
return ['multipart' => $multipart];
@@ -477,11 +478,6 @@ public static function getCurrentAction()
477478
*/
478479
public static function execute($action, array $data = [])
479480
{
480-
//Fix so that the keyboard markup is a string, not an object
481-
if (isset($data['reply_markup'])) {
482-
$data['reply_markup'] = json_encode($data['reply_markup']);
483-
}
484-
485481
$result = null;
486482
$request_params = self::setUpRequestParams($data);
487483
$request_params['debug'] = TelegramLog::getDebugLogTempStream();

0 commit comments

Comments
 (0)