Skip to content

Convert all data object fields to JSON strings. #991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,16 @@ private static function setUpRequestParams(array $data)
if (is_string($item) && file_exists($item)) {
$item = new Stream(self::encodeFile($item));
}
} elseif (is_array($item)) {
// Convert any nested arrays into JSON strings.
} elseif (is_array($item) || is_object($item)) {
// Convert any nested arrays or objects into JSON strings.
$item = json_encode($item);
}

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

if ($has_resource) {
return ['multipart' => $multipart];
Expand Down Expand Up @@ -479,11 +480,6 @@ public static function getCurrentAction()
*/
public static function execute($action, array $data = [])
{
//Fix so that the keyboard markup is a string, not an object
if (isset($data['reply_markup'])) {
$data['reply_markup'] = json_encode($data['reply_markup']);
}

$result = null;
$request_params = self::setUpRequestParams($data);
$request_params['debug'] = TelegramLog::getDebugLogTempStream();
Expand Down