简体   繁体   中英

Guzzle 6 POST request

Im just want to ask if anyone knows how i can post multiple data with the POST request. This works:

$data = array(
'post_params'=>[
  'Name'=>'Foo',
  'LastName'=>'Bar'
]
);

This dosent work: any alternatives?

$data = array(
'post_params'=>[
  'Name'=>'Foo',
  'LastName'=>'Bar'
],
'post_params'=>[
  'Name'=>'Foo',
  'LastName'=>'Bar'
]
);

Ho can i send multiple post data at once?

You can't do it that way just because that's not how requests work, you can append nearly as many attributes as you want, but not nested arrays of data.

Gonna have to do it this way:

 $data = array( 'post_params'=>[ 'Name1'=>'Foo', 'LastName1'=>'Bar', 'Name2'=>'Foo', 'LastName2'=>'Bar' ] ); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM