php-mod/curl

Use http_build_query on POSTFILEDS values.

Closed this issue · 2 comments

I got the problem, that your Curl class can't handle multidimensional arrays for certain methods - data (and maybe all others that use the POSTFIELDS).

$curl = new Curl();
$curl->patch('some-endpoint', ['multi'=>['dimensional' => ['data'] => 'payload']]);

This will throw an error, that string was excepted but got array, so it did an Array=>string conversion.

The correct usage would be to use http_build_query on the POSTFIELDS data so it will get converted into the correct scheme and won't raise an error anymore.

Currently it would create an request with the following "payload"

multi=Array

But it would be more correct to have the request body:

multi[dimensional][data]=payload

EDIT: Just saw that POST already does this, but patch for example, does not.

I am working on a 2.0 version, this version will supports multi array and uses the latest PHP and cURL features. Soon I will publish a beta release of it.

nadar commented

I am going to close this issue because:

  • Missing information's
  • No more activity
  • No one picked up the task (no Pull Request received)

If you think this is still important or there are more/new informations. Please reopen the issue and let us know.