Skip to content

Commit 75fc62e

Browse files
authored
Merge pull request #991 from noplanman/allow_native_data_objects
Convert all data object fields to JSON strings.
2 parents 7ebce6a + 8a363b2 commit 75fc62e

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
@@ -373,15 +373,16 @@ private static function setUpRequestParams(array $data)
373373
if (is_string($item) && file_exists($item)) {
374374
$item = new Stream(self::encodeFile($item));
375375
}
376-
} elseif (is_array($item)) {
377-
// Convert any nested arrays into JSON strings.
376+
} elseif (is_array($item) || is_object($item)) {
377+
// Convert any nested arrays or objects into JSON strings.
378378
$item = json_encode($item);
379379
}
380380

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

386387
if ($has_resource) {
387388
return ['multipart' => $multipart];
@@ -479,11 +480,6 @@ public static function getCurrentAction()
479480
*/
480481
public static function execute($action, array $data = [])
481482
{
482-
//Fix so that the keyboard markup is a string, not an object
483-
if (isset($data['reply_markup'])) {
484-
$data['reply_markup'] = json_encode($data['reply_markup']);
485-
}
486-
487483
$result = null;
488484
$request_params = self::setUpRequestParams($data);
489485
$request_params['debug'] = TelegramLog::getDebugLogTempStream();

0 commit comments

Comments
 (0)