php - CakePHP HttpSockets send array of paramms -


i problem when make request (i can request).

$link = 'http://uri/path/?param1=1&sid=2&sid=3&sid=4' $http = $httpsocket = new httpsocket(); $res = $httpsocket->get($link); if check request

pr($http); 

i see :

[line] => /url/path/?param1=1&sid%5b0%5d=2&sid%5b1%5d=3&sid%5b2%5d=4 http/1.1 

and i'm getting empty response because server doesn't know parameters sid%5b0%5d=2

when try send parameters array : $data = array('param1' => '1', 'sid' => array('2','3', '4'));

i see same changes %5b0%5d - additional indexes.

how fix it?

unfortunately , can not change server side, if send request in browser, i'll normal response in json format.

when make request, can parameters this:

  • $param1 = $_get['param1'];
  • $sid= $_get['sid'];

tip: use diferente names parameters. have multiples sid. use sid1, sid2, sid3...

update: can parameters this:

$link = 'http://uri/path/?param1=1&sid=2&sid=3&sid=4';  $query_str = parse_url($link, php_url_query); parse_str($query_str, $query_params); print_r($query_params); 

reference: how parameters url string?


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -