Get method does not send data properly.
MohammadZarifiyan opened this issue · 0 comments
MohammadZarifiyan commented
- PHP Version: 8.0
Description:
Get parameters is sent like this:
param1=value1 ; param2=value2 ; ....
instead of this:
param1=value1 & param2=value2 & ....
Steps To Reproduce:
use Illuminate\Support\Facades\Http;
Http::get('http://example.com', ['param1'=>'value1', 'param2'=>'value2',....]);
I solved that by using urlencode()
:
$data = ['param1'=>'value1', 'param2'=>'value2',....];
$data = urlencode($data);
Http::get('http://example.com', $data);
but still has problem, because nested arrays does not receive properly by the endpoint server.
for example:
Http::get('http://api.telegram.org/bot[API_TOKEN]/sendMessage',[
'chat_id' => 123456789,
'text' => 'Hello there',
'reply_markup' => [
'keyboard' => [
[['text' => 'Some random button title']]
]
],
]);
Telegram cannot process reply_markup, so does not show a keyboard to user.
But, when I use CURL to send above data to telegram (using GET method), it works properly.