diff --git a/Proxy.php b/Proxy.php index 5691aea..2d1636b 100644 --- a/Proxy.php +++ b/Proxy.php @@ -293,6 +293,21 @@ protected static function getIncomingRequestHeaders($skippedHeaders = []) return $results; } + // https://gist.github.com/yisraeldov/ec29d520062575c204be7ab71d3ecd2f + protected static function build_post_fields( $data,$existingKeys='',&$returnArray=[]){ + if(($data instanceof CURLFile) or !(is_array($data) or is_object($data))){ + $returnArray[$existingKeys]=$data; + return $returnArray; + } + else{ + foreach ($data as $key => $item) { + static::build_post_fields($item,$existingKeys?$existingKeys."[$key]":$key,$returnArray); + } + return $returnArray; + } + } + + /** * @param string $targetURL * @return false|resource @@ -324,7 +339,7 @@ protected static function createRequest($targetURL) } } - curl_setopt($request, CURLOPT_POSTFIELDS, $data + $_POST); + curl_setopt($request, CURLOPT_POSTFIELDS, static::build_post_fields($data + $_POST)); } $headers = static::getIncomingRequestHeaders(static::getSkippedHeaders());